Private Sub Command1_Click() Dim cnConnection As ADODB.Connection Dim rsMain As ADODB.Recordset Set cnConnection = New ADODB.Connection Set rsMain = New ADODB.Recordset cnConnection.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=Файлы dBASE;Initial Catalog=C:\" cnConnection.Open Debug.Print "Connection.State = " & cnConnection.State Set rsMain.ActiveConnection = cnConnection rsMain.Source = "select P1, P2 from Test" rsMain.Open Debug.Print "rsMain.State = " & rsMain.State If cnConnection.State = adStateOpen Then cnConnection.Close If Not rsMain Is Nothing Then Set rsMain = Nothing End Sub
Ответить
|