vb.net 怎么把DataGridView 数据源 设为adodb
DimconnAsADODB.ConnectionDimrsAsADODB.RecordsetDimsql,conn_strAsString'conn_str="Prov...
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sql, conn_str As String
'conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\My Documents\Visual Studio 2008\仓库\WindowsApplication1\ck.mdb;Persist Security Info=False "
conn_str = ConfigurationManager.ConnectionStrings("myconnectionstring").ConnectionString
sql = "select * from us "
conn = New ADODB.Connection
conn.Open(conn_str)
rs = New ADODB.Recordset
rs.Open(sql, conn, 3, 3)
DataGridView1.DataSource = rs
DataGridView1.Refresh()
这是我的代码.可是运行时 DataGridView1没有反应.
数据是可以查出来的
我用TextBox1.Text = rs(1).Value 试过.可以显示信息。 展开
Dim rs As ADODB.Recordset
Dim sql, conn_str As String
'conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\My Documents\Visual Studio 2008\仓库\WindowsApplication1\ck.mdb;Persist Security Info=False "
conn_str = ConfigurationManager.ConnectionStrings("myconnectionstring").ConnectionString
sql = "select * from us "
conn = New ADODB.Connection
conn.Open(conn_str)
rs = New ADODB.Recordset
rs.Open(sql, conn, 3, 3)
DataGridView1.DataSource = rs
DataGridView1.Refresh()
这是我的代码.可是运行时 DataGridView1没有反应.
数据是可以查出来的
我用TextBox1.Text = rs(1).Value 试过.可以显示信息。 展开
1个回答
展开全部
这样就OK了
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sql, conn_str As String
'conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\My Documents\Visual Studio 2008\仓库\WindowsApplication1\ck.mdb;Persist Security Info=False "
conn_str = ConfigurationManager.ConnectionStrings("myconnectionstring").ConnectionString
sql = "select * from us "
conn = New ADODB.Connection
conn.Open(conn_str)
rs = New ADODB.Recordset
rs.Open(sql, conn, 3, 3)
Dim da As New System.Data.OleDb.OleDbDataAdapter
Dim ds As New DataSet
da.Fill(ds, rs, "us")
DataGridView1.DataSource = ds.Tables(0)
DataGridView1.Refresh()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sql, conn_str As String
'conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\My Documents\Visual Studio 2008\仓库\WindowsApplication1\ck.mdb;Persist Security Info=False "
conn_str = ConfigurationManager.ConnectionStrings("myconnectionstring").ConnectionString
sql = "select * from us "
conn = New ADODB.Connection
conn.Open(conn_str)
rs = New ADODB.Recordset
rs.Open(sql, conn, 3, 3)
Dim da As New System.Data.OleDb.OleDbDataAdapter
Dim ds As New DataSet
da.Fill(ds, rs, "us")
DataGridView1.DataSource = ds.Tables(0)
DataGridView1.Refresh()
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询