Solved

insert into database probs using sql

Posted on 2000-04-10
7
143 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
  • 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 69

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 69

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now