vb.net连接ACCESS数据库怎么用OleDbDataReader输出数据库中的表格
vb.net连接ACCESS数据库怎么用OleDbDataReader输出数据库中的表格(*不是全部输出选几列输出)
Private Sub 添加1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 添加1.Click
myconn.Close()
mycmd.Connection = myconn
mycmd.CommandText = "select * FROM 商品信息 WHERE 商品信息.商品编号='" & textbox2.Text.Trim() & "'"
myconn.Open()
Dim mydatareader As OleDbDataReader
mydatareader = mycmd.ExecuteReader()
mydatareader.Read()
Me.textbox1.Text = mydatareader.Item("商品条码")
If Me.textbox1.Text = mydatareader.Item("商品条码") Then
j += 1
Me.lb1.Text = j
End If
Me.TextBox3.Text = mydatareader.Item("商品名称")
DataGridView1 = ???????????????????????????、输出商品条码,商品数量,商品名称
------解决方案-------------------- Dim _datatable As New System.Data.DataTable()
Dim _oledbdataadapter As New OleDbDataAdapter("select 输出商品条码,商品数量,商品名称 from 商品信息 WHERE 商品信息.商品编号='" & textbox2.Text.Trim() & "'", mycon)
_oledbdataadapter.Fill(_datatable)
DataGridView2.DataSource = _datatable