新手用VB编的对ACCESS表格查询程序出问题了,求指导
有这样一个表格,字段有GZMS,YY,GLBZ。在text输入GZMS信息,点击查询,显示相应的其它信息。我编写的程序如下:
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(TextGZMS.Text) <> "" Then
WhereStr = "GZMS like Trim(TextGZMS.Text) "
End If
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source" & "='E:\SY.mdb'"
= "Select YY,GLBZ From 表1"
If WhereStr <> "" Then
= & "where" & WhereStr
End If
objComm.Connection = objConn
objDa.SelectCommand = objComm
objConn.Open()
objDa.Fill(objDs, "表1")————————调试运行的时候点击查询查不出,说我这里出问题,其实我这新手也不知道这行是干什么用的
objConn.Close()
DataGridView1.DataSource = objDs.Tables("表1")
End Sub
求指导啊