如何将 DataGridView 中的多行添加到数据库中的表中?
在我的 DataGridView 中,大约有 2 或 3 行关于供应商数据 它与供应商数据有关,因为我可能从 2 或 3 个供应商那里获得一种产品 当我单击按钮(确认添加)时,如何从数据网格视图将供应商ID(FK)添加到数据库中的产品表并避免数据冗余 我认为它可能会将 2 或 3 个供应商 ID 保存为记录,但我不知道该怎么做?
in my DataGridView there are about 2 or 3 rows about the Supplier data
it is about Supplier data ,,as there might be one product i get from 2 or 3 suppliers
how to add the Suppliers_ID (FK) to the Product table in the data base from the data grid view when i click on a button (Confirm adding) and to avoid the data redundancy
i think it might be saving the 2 or 3 Suppliers_ID as Records but i donknow how to do this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在两个表之间创建主从关系。以下链接适用于 DataGrid,但您可以对 DataGridView 使用相同的逻辑:
http://msdn.microsoft.com/en-us/library/59y45529(vs.100).aspx
希望这会有所帮助。
You need to create a master-detail relationship between your two tables. This below link is for DataGrid but you can use the same logic for DataGridView:
http://msdn.microsoft.com/en-us/library/59y45529(vs.100).aspx
Hope this helps.