[英]Setting data to DataGridView in VB.net
I have a DataGridView on windows Form, just draged and droped from tools. 我在Windows Form上有一个DataGridView,只需将其拖放到工具中即可。 Now I want to set data to this gridview using DataSet or DataTable.
现在,我想使用DataSet或DataTable将数据设置到此gridview。 How can set it by coding.
如何通过编码设置。 I am using SQL Server 2008 and VS 2010
我正在使用SQL Server 2008和VS 2010
Please Help me.... 请帮我....
here's a quick example: 这是一个简单的例子:
Dim DS As New DataSet()
昏暗的DS作为新的DataSet()
Dim DA As New SqlDataAdapter()昏暗的DA作为新的SqlDataAdapter()
Dim SelectQ as String = Query昏暗的SelectQ作为字符串=查询
Dim CN As New SqlConnection(ConnectionString)Dim CN作为新的SqlConnection(ConnectionString)
DA.SelectCommand = New SqlClient.SqlCommand(SelectQ) DACustomers.SelectCommand.Connection = CNDA.SelectCommand =新建SqlClient.SqlCommand(SelectQ)DACustomers.SelectCommand.Connection = CN
CN.Open中国公开赛
DA.fill(DS, "diseredTable")DA.fill(DS,“ diseredTable”)
CN.Close关闭
Dim BS As New BindingSource昏暗的BS作为新的BindingSource
BS.DataSource = DSBS.DataSource = DS
BS.DataMember = ”desiredTable”BS.DataMember =“所需表”
DataGridView1.DataSource = BSDataGridView1.DataSource = BS
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.