btnUpdate_Click() Question in VBA
Got it as follows: don't forget to go Tools/References and add Microsoft
ActiveX 2.5 or .
Private Sub btnUpdate_Click()
Dim c As ADODB.Connection
Dim r As ADODB.Recordset
Set c = New ADODB.Connection
Dim rw As Integer
strCn = "Server=ServerName;Database=DbName;User Id=marc;password=mm"
c.Provider = "sqloledb"
c.Open strCn
rw = 2
Do While Len(Cells(rw, 8)) 0
'sq = "Insert into marc_temp_excel (comment) values ('Marc')"
Set r = c.Execute(sq)
rw = rw + 1
Loop
c.Close
MsgBox ("marc_temp_excel Table Successfully Updated.")
End Sub
|