Dim objRs As New Recordset, objCn As New Connection, strSQL As String
strSQL = "SELECT * FROM 表 WHERE 字段 like '" & Trim(Text) & "'"
With objCn
.Provider = "SQLOLEDB"
.ConnectionString = "provider=MSDASQL.1;persist security info=false;Data Source=数据源 (ODBC)"
.Open
End With
With objRs
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open strSQL
End With
Set DataGrid.DataSource = objRs
`````````````````````````````````````````````
' 数据源 (ODBC)----------hhdb
Dim objRs As New Recordset, objCn As New Connection, strSQL As String
strSQL = "SELECT * FROM " & Combo.Text '表
With objCn
.Provider = "SQLOLEDB"
.ConnectionString = "provider=MSDASQL.1;persist security info=false;Data Source=hhdb"
.Open
End With
If Combo.Text = "" Then
Combo.BackColor = &H80000013
Else
With objRs
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open strSQL
End With
Set DataGrid.DataSource = objRs
Me.Caption = DataGrid.ApproxCount
End If