如何在 DataGridView 中显示数据集中的两个表
我有一个包含 2 个不同表的数据集。我要做的就是在 DataGridView 中显示这些表。下面给出了我所做的参考。
sqlCmd.CommandText = "AutomateKDB"
sqlCmd.CommandType = CommandType.StoredProcedure
sqlCmd.Connection = Connection
sqlCmd.ExecuteNonQuery()
sqlDaK1 = New SqlDataAdapter(sqlCmd)
sqlDaK1.Fill(Kds, "KA")
sqlCmdeA.CommandText = "AutomateeAudIT_KAData"
sqlCmdeA.CommandType = CommandType.StoredProcedure
sqlCmdeA.Connection = Connection1
sqlCmdeA.ExecuteNonQuery()
sqlDaeK1 = New SqlDataAdapter(sqlCmd)
sqlDaeK1.Fill(Kds, "eK")
GridKnowledge.DataSource = Kds
但这是行不通的。请帮我解决这个问题。
提前致谢。,
I have a Dataset with 2 different tables. What I have to do is to display those tables in a DataGridView. What I have done with a reference is given below.
sqlCmd.CommandText = "AutomateKDB"
sqlCmd.CommandType = CommandType.StoredProcedure
sqlCmd.Connection = Connection
sqlCmd.ExecuteNonQuery()
sqlDaK1 = New SqlDataAdapter(sqlCmd)
sqlDaK1.Fill(Kds, "KA")
sqlCmdeA.CommandText = "AutomateeAudIT_KAData"
sqlCmdeA.CommandType = CommandType.StoredProcedure
sqlCmdeA.Connection = Connection1
sqlCmdeA.ExecuteNonQuery()
sqlDaeK1 = New SqlDataAdapter(sqlCmd)
sqlDaeK1.Fill(Kds, "eK")
GridKnowledge.DataSource = Kds
But this is not working. Please help me with this.
Thanks In Advance.,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用两个不同的 DataGridView 或嵌套它们。查看 MSDN 文章 - 分层数据的嵌套网格和代码项目文章 - 具有分层数据绑定的 DataGridView
You can use two different DataGridView or nest them. Take a look at MSDN article - Nested Grids for Hierarchical Data and Code Project article - DataGridView with hierarchical data binding
您查看两个表。
注意表中的相同字段,选择其中之一
You make view of two tables .
Note same field in tables, select one of them
这是不久前发布到 msdn 论坛上的解决方案。
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/0a63a483-5b15-40d6-afb4-8add6b4f244f
或者,您可以考虑混合使用 winform 和 wpf ,我相信这相对容易......
Here's a solution that was posted to the msdn forums sometime ago.
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/0a63a483-5b15-40d6-afb4-8add6b4f244f
Alternatively, you might consider mixing winform and wpf, where I believe this is relatively easy...