insert into database probs using sql

sql = "UPDATE Customers " & _
       "SET CompanyName = '" & Text2.Text & "'," & _
       "CompanyAddress  = '" & Text3.Text & "', " & _
       "Town or City    = '" & Text4.Text & "'," & _
       "County          = '" & Text5.Text & "'," & _
       "PostalCode      = '" & Text6.Text & "'," & _
       "Country         = '" & Text7.Text & "'," & _
       "PhoneNumber     = '" & Text8.Text & "'," & _
       "FaxNumber       = '" & Text9.Text & "'," & _
       "Notes           = '" & Text10.Text & "'" & _
       "WHERE CustomerID= '" & Text1.Text & "'"
dbAddress.Execute sql

i keep getting a run-time error when i run this the error is -2147217900(80040e14)
Slightly_ImperfectAsked:
Who is Participating?
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
So I guess that I am the one that put you on track?
0
 
caraf_gCommented:
Put a space before the "WHERE...

change it to  " WHERE....
0
 
caraf_gCommented:
PS, you should also replace embedded single quotes with two single quotes

_
       "SET CompanyName = '" & Text2.Text & "'," & _
       
Should be

_
       "SET CompanyName = '" & Replace(Text2.Text, "'", "''") & "'," & _
       

Please note "'" = A string consisting of one single quotes
"''" = A string consisting of two single quotes, *NOT* one double quote...
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
guyssCommented:
also, the final sql string should look like:

UPDATE tbl set companyname='blablabla'
so put single quotes before and after you textfield.
0
 
Éric MoreauSenior .Net ConsultantCommented:
This line:
"Town or City = '" & Text4.Text & "',"  

Should be read as:
"[Town or City] = '" & Text4.Text & "',"  

Because queries can't have spaces in name of fields or tables or ...
0
 
Slightly_ImperfectAuthor Commented:
i sussed out what the problem was  

town and city should have been put like this


`Town and City` that was it !!!

works fine now thanks for all your help !!!!!


:>)

 
0
 
Slightly_ImperfectAuthor Commented:
i will give you the points just because i am feeling nice !!!! but i had sorted it out before i logged back on :p

cheers anyway !!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.