Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 13th, 2008, 04:03 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: West Palm Beach, Florida, USA.
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default Insert renders error

Trying to insert a record using variables from a data set. Get error on variable myRow.Item(63).


insert into rjadevlib.f5514ar (f1, f2, f3) " values(" & "'" myRow.Item(63) & "'" & "," & "'" & myRow.Item(64) & "'" & "," & "'" & myRow.Item(65) & "'" & ")"


The content is:

insert into rjadevlib.f5514ar(f1, f2, f3) values('101 Sansbury's Way ','West Palm Beach ','Fl')


SQL0104: Token S was not valid. Valid tokens: ) ,.
Cause . . . . . : A syntax error was detected at token S. Token S is not a valid token.

Is there a way around this? I would like to test the variable "myRow.Item(63)" beforehand

Reply With Quote
  #2 (permalink)  
Old October 13th, 2008, 05:42 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You need to escape the ' in Sansbury's.

So you would need to execute the insert the as:
insert into rjadevlib.f5514ar(f1, f2, f3) values('101 Sansbury''s Way ','West Palm Beach ','Fl')

hth.


================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
Reply With Quote
  #3 (permalink)  
Old October 13th, 2008, 09:28 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Since you are using VB, it's easy to do the escaping DParsons noted:
Code:
... = "insert into rjadevlib.f5514ar (f1, f2, f3) " _
    & " values('" Replace(myRow.Item(63),"'","''") & "'," _
    & "'" & Replace(myRow.Item(64),"'","''") & "'," _
    & "'" & Replace(myRow.Item(65),"'","''") & "')"
But can't you come up with better names for your DB fields than f1, f2, and f3????
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
DataGrid renders different on different machines GertFrost ASP.NET 2.0 Basics 1 June 19th, 2007 03:34 PM
DataGrid renders different on different machines GertFrost ASP.NET 2.0 Professional 1 May 25th, 2006 10:21 PM
dw renders my css when previewed in browser? jakewilliamson Dreamweaver (all versions) 5 March 21st, 2005 05:42 AM



All times are GMT -4. The time now is 12:16 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.