Dim conn As New ADODB.Connection
With conn
.Provider = "SQLOLEDB"
.ConnectionString = "DATA SOURCE=(local);" & _
"INITIAL CATALOG=YY;" & _
"User ID = sa; Password=abc"
.Open
End With
Dim strSQl As String
strSQl = "Select * from 表1"
Dim rs As New ADODB.Recordset
rs.Open strSQl, conn, adOpenKeyset, adLockBatchOptimistic
Set grd.DataSource = rs
Text1.Text = rs("字段a")