Private Sub Command4_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
rs.CursorLocation = adUseClient
ConnectionString = "Provider=SQLOLEDB.1;Password=1234;Persist Security Info=True;User ID=sa;Initial Catalog=csjxcglxt;Data Source=TANGJIANQIAO-PC"
cn.Open ConnectionString
If Text1.Text = "" Then
MsgBox "请填写关键词!", vbExclamation, "提示信息"
Exit Sub
End If
rs.Open "select * from 商品信息表 where
" & Combo1.Text & "" & " like '" & Text1.Text & "'", cn, adOpenKeyset, adLockOptimistic
If rs.RecordCount = 0 Then
MsgBox "没有这条记录!", vbExclamation, "提示信息"
End If
Set DataGrid1.DataSource = rs
DataGridRows = rs.RecordCount
End Sub