Kod:
Private Sub CommandButton1_Click()
Dim SQL As String
Dim ADO_RS As ADODB.Recordset
Dim ADO_CN As ADODB.Connection
SQL = "SELECT * FROM Sorgu1 WHERE Ad = 'Fatih'"
Set ADO_RS = New ADODB.Recordset
Set ADO_CN = New ADODB.Connection
ADO_CN.ConnectionString = "provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & ThisWorkbook.Path & "\Örnek.accdb;"
ADO_CN.Open
ADO_RS.Open SQL, ADO_CN, 3, 1 ' güncelleme yapabilmek için 1,3 0lmalı yada adOpenKeyset, adLockOptimistic
Sheets("Sayfa1").Range("A4") = ADO_RS.Fields("Ad")
son:
ADO_RS.Close
ADO_CN.Close
Set ADO_RS = Nothing
Set ADO_CN = Nothing
Dim SQL As String
Dim ADO_RS As ADODB.Recordset
Dim ADO_CN As ADODB.Connection
SQL = "SELECT * FROM Sorgu2 WHERE Ad = 'Nur'"
Set ADO_RS = New ADODB.Recordset
Set ADO_CN = New ADODB.Connection
ADO_CN.ConnectionString = "provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & ThisWorkbook.Path & "\Örnek.accdb;"
ADO_CN.Open
ADO_RS.Open SQL, ADO_CN, 3, 1 ' güncelleme yapabilmek için 1,3 0lmalı yada adOpenKeyset, adLockOptimistic
Sheets("Sayfa1").Range("A5") = ADO_RS.Fields("Ad")
son:
ADO_RS.Close
ADO_CN.Close
Set ADO_RS = Nothing
Set ADO_CN = Nothing
End Sub