W.E.B
asked on
SQL Update Excel vba
Hello,
can you please help,
I'm trying to update an email address.
I don't get any errors, but nothing gets updated.
Sub UPDATE_Drivers_Emails()
Dim sh As Worksheet
Set sh = Sheets("Emails_Driver")
Dim cnn As New adodb.Connection
Set cnn = New adodb.Connection
Dim strSQL As String
' sTART
cnn.Open "Provider=SQLOLEDB.1;User ID=sa; password=xxxxxxxxx;Initial Catalog=Cccccccccccc;Data Source=Wassim-XPS;"
strSQL = "Update Drivers set Email ='" & sh.[J1].Value & "' where ((DriverNumber = '" & sh.[M1].Value & "'))"
cnn.BeginTrans
cnn.CommitTrans
cnn.Close
Set cnn = Nothing
MsgBox "Updated"
End Sub
can you please help,
I'm trying to update an email address.
I don't get any errors, but nothing gets updated.
Sub UPDATE_Drivers_Emails()
Dim sh As Worksheet
Set sh = Sheets("Emails_Driver")
Dim cnn As New adodb.Connection
Set cnn = New adodb.Connection
Dim strSQL As String
' sTART
cnn.Open "Provider=SQLOLEDB.1;User ID=sa; password=xxxxxxxxx;Initial
strSQL = "Update Drivers set Email ='" & sh.[J1].Value & "' where ((DriverNumber = '" & sh.[M1].Value & "'))"
cnn.BeginTrans
cnn.CommitTrans
cnn.Close
Set cnn = Nothing
MsgBox "Updated"
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello,
I dropped the single Quote
I get a message
Update Drivers Set Email = 'xxxxx@xxxxxx.om' where (DriverNumber = 2002)
Nothing gets updated though in SQL,
thanks
I dropped the single Quote
I get a message
Update Drivers Set Email = 'xxxxx@xxxxxx.om' where (DriverNumber = 2002)
Nothing gets updated though in SQL,
thanks
ASKER
thank you
this is what I missed.
cnn.Execute strSQL
this is what I missed.
cnn.Execute strSQL
ASKER
Thank you
Open in new window
Then write down what is displayed in this question.At a glance, if DriverNumber is a number then lose the single quote marks ' surrounding the value.