Private Sub CommandButton1_Click()
Dim Baglanti As New ADODB.Connection
Dim KayitSeti As New ADODB.Recordset
Dim Firma As String, Server As String, Database As String, Kullanıcı As String, Parola As String
Firma = Format(Sheets("SETUP").Range("B5"), "000")
Server = Sheets("SETUP").Range("B1").Value
Database = Sheets("SETUP").Range("B4").Value
Kullanıcı = Sheets("SETUP").Range("B2").Value
Parola = Sheets("SETUP").Range("B3").Value
sorgu = "SELECT CODE,DEFINITION_ FROM LG_" & Format(Sheets("SETUP").Range("B5"), "000") & "_CLCARD " & "ORDER BY DEFINITION_" & ""
Baglanti.Open "Provider=SQLOLEDB; Data Source=" & Server & "; Initial Catalog=" & Database & "; User ID=" & Kullanıcı & "; Password=" & Parola & ";"
KayitSeti.Open sorgu, Baglanti
Cells(8, 1).CopyFromRecordset KayitSeti
KayitSeti.Close
Baglanti.Close
Set KayitSeti = Nothing
Set Baglanti = Nothing
End Sub
bu kodda hata alıyorum ayarları resimdeki gibide yaptım yardım lütfen