Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

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)
0
Slightly_Imperfect
Asked:
Slightly_Imperfect
  • 2
  • 2
  • 2
  • +1
1 Solution
 
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
 
guyssCommented:
also, the final sql string should look like:

UPDATE tbl set companyname='blablabla'
so put single quotes before and after you textfield.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
É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
 
Éric MoreauSenior .Net ConsultantCommented:
So I guess that I am the one that put you on track?
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now