为什么这段程序无效?(vb数据库)
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
cn.Close
End
End Sub
Private Sub Form_Load()
cn.Provider = "SQLOLEDB.1"
cn.Properties("Persist Security Info").Value = "False"
cn.Properties("User ID").Value = "sa"
cn.Properties("Initial Catalog").Value = "pubs"
cn.Properties("Data Source").Value = "192.168.0.247"
'cn.Properties("Integrated Security").Value = "SSPI"
'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Northwind;Data Source=192.168.0.247
cn.Open
Set rs.ActiveConnection = cn
rs.Source = "Products"
rs.CursorType = adOpenForwardOnly
rs.LockType = adLockReadOnly
rs.Source = "select * from products"
rs.Open
If rs.RecordCount > 0 Then
Set DataGrid1.DataSource = rs
End If
End Sub