下面是我的代码,但好象没有效果,不知是怎么回事,请那位高手帮看一下,指点一二。
Dim ZDM As String
Try
'construct the command object and open a connection to the Contacts table
Dim cmdString As String = "Select ZDM from DZB WHERE ZMC = " & Grid1.Cell(j, 4).Text & " "
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=hjsby.mdb"
Dim myConnection As OleDbConnection = New OleDbConnection(connString)
' Open connection
myConnection.Open()
'Create OleDbCommand object
Dim TheCommand As OleDbCommand = New OleDbCommand(cmdString, myConnection)
TheCommand.CommandType = CommandType.Text
' Create a DataReader and call Execute on the Command Object to construct it
Dim TheDataReader As OleDbDataReader = TheCommand.ExecuteReader()
While TheDataReader.Read()
ZDM = TheDataReader("ZDM").ToString()
End While
Catch ae As OleDbException
MsgBox(ae.Message())
End Try