在绑定数据网格中的数据时需要帮助 [英] need help in binding data in a datagrid
本文介绍了在绑定数据网格中的数据时需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
Hi all
Dim ds1 As New DataSet()
'Dim ds As New DataSet()
Dim sql1 As String = "SELECT sum(present) FROM attendance where present='1' and Emp_id='" & TextBox1.Text & "'"
Dim connection As New SqlConnection(str)
Dim dataadapter1 As New SqlDataAdapter(sql1, str)
connection.Open()
dataadapter1.Fill(ds1, "attendance")
'ds.Tables(0).Rows(0)(0) = ds1.Tables(0).Rows(0)(0)
DataGridView2.DataSource = ds1.Tables(0).Rows(0)(0)
connection.Close()
'DataGridView2.DataSource = ds1.Tables(0).Rows(0)(0)
'DataGridView2.DataMember = "attendance"
我写了上面的代码将值绑定到datagrid的特定列中.但是它不起作用..请告诉我问题..
并且我编写了一个具有3个值的相同函数,并将其绑定到同一datagrid中.
i wrote the above code to bind a value in a specific column in a datagrid.but it''s not working..please tell me the problem..
and i wrote one same function with 3 values which i am binding in the same datagrid.
推荐答案
只需使用数据绑定即可从数据库中检索数据
Just use databinding to retireve data from database
这篇关于在绑定数据网格中的数据时需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文