菜鸟求救
vb.net吧
全部回复
仅看楼主
level 1
用vb.net连接Access数据库了,想用label显示查询到内容,帮写一下具体代码,谢谢
2016年11月03日 01点11分 1
level 1
Dim objConn As New OleDb.OleDbConnection
Dim objDa As New OleDb.OleDbDataAdapter
Dim objComm As New OleDb.OleDbCommand
Dim objDs As New DataSet
Dim a As String
a = ""
If TextBox1.Text <> "" Then
a = "ChengYu like '%" + TextBox1.Text + "%'"
End If
objConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = ChengYu.accdb"
objComm.CommandText = "Select ChengYu as 成语,PingYin as 拼音,DianGu as 解释 From ChengYuDaQuan"
If a <> "" Then
objComm.CommandText = objComm.CommandText & " where " & a
End If
objComm.Connection = objConn
objDa.SelectCommand = objComm
objConn.Open()
objDa.Fill(objDs, "ChengYuDaQuan")
objConn.Close()
DataGridView1.DataSource = objDs.Tables("ChengYuDaQuan")
2016年11月03日 01点11分 2
level 1
不想用DataGridView,想用laebl,求帮改
2016年11月03日 01点11分 3
1