新手用VB编的对ACCESS表格查询程序为什么全部都会显示,求指导
程序修改了半天终于没错了,但是在 text里面输入信息 要查询表里与 描述 这个字段相符的那一行信息,结果点查询以后不是查到想要的那行,而是全部显示出来,这是怎么个情况 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objConn As New OleDb.OleDbConnection
Dim objDa As New OleDb.OleDbDataAdapter
Dim objComm As New OleDb.OleDbCommand
Dim objDs As New DataSet
Dim WhereStr As String
WhereStr = ""
If Trim(TxtMS.Text) <> "" Then
WhereStr = " 描述 like " + Trim(TxtMS.Text)
End If
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source" & "='E:\cx.mdb'"
= "Select * From 表1 "
If WhereStr <> "" Then
= & " where " & "'" & WhereStr & "'"
End If
objComm.Connection = objConn
objDa.SelectCommand = objComm
objConn.Open()
objDa.Fill(objDs, "表1")
DataGridView1.DataSource = objDs.Tables("表1")
objConn.Close()
End Sub