Solved

insert into database probs using sql

Posted on 2000-04-10
7
150 Views
Last Modified: 2010-05-18
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
Comment
Question by:Slightly_Imperfect
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 10

Expert Comment

by:caraf_g
ID: 2700279
Put a space before the "WHERE...

change it to  " WHERE....
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2700291
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
 
LVL 1

Expert Comment

by:guyss
ID: 2700331
also, the final sql string should look like:

UPDATE tbl set companyname='blablabla'
so put single quotes before and after you textfield.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2700382
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
 

Author Comment

by:Slightly_Imperfect
ID: 2701322
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
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 10 total points
ID: 2701362
So I guess that I am the one that put you on track?
0
 

Author Comment

by:Slightly_Imperfect
ID: 2703901
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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month5 days, 1 hour left to enroll

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question