Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
rs.CursorLocation = adUseClient
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=data.mdb;Persist Security Info=False" '
cn.Open ConnectionString
If Text1.Text = " " Then
MsgBox "请输入要查询的姓名!", vbExclamation, "提示信息"
Exit Sub
End If
rs.Open "select * from 电话本 where 名字 = '" & Text1.Text & " '", cn, adOpenKeyset, adLockOptimistic
If rs.RecordCount = 0 Then
MsgBox "没有此人!", vbExclamation, "提示信息"
End If
Set DataGrid1.DataSource = rs
DataGridRows = rs.RecordCount
End Sub
[此贴子已经被作者于2007-9-5 12:51:45编辑过]