V referencích VBA přidat referenci na Microsoft ActiveX Data Objects 2.8 Library.
a pak následující kód...
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=NazevDB;Data Source=NazevServeru"
conn.Open
For rd = 2 To ActiveSheet.UsedRange.Rows.Count
If Cells(rd, 1) <> "" Then
conn.Execute ("INSERT INTO TABULKA (JMENO, CAS, DUVOD) VALUES ('" & Cells(rd, 1) & "', " & Cells(rd, 2) & ", '" & Cells(rd, 3) & "'")
End If
Next
conn.Close
Použitý connection string využívá ověření windows, nikoliv SQL.
M@citovat
a pak následující kód...
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=NazevDB;Data Source=NazevServeru"
conn.Open
For rd = 2 To ActiveSheet.UsedRange.Rows.Count
If Cells(rd, 1) <> "" Then
conn.Execute ("INSERT INTO TABULKA (JMENO, CAS, DUVOD) VALUES ('" & Cells(rd, 1) & "', " & Cells(rd, 2) & ", '" & Cells(rd, 3) & "'")
End If
Next
conn.Close
Použitý connection string využívá ověření windows, nikoliv SQL.
M@citovat