Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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
 
Old June 20th, 2004, 01:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default Incorrect syntax......

Hi there

I've got a varchar column in my SQL db - when I go to insert some data I get an error like this:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 've'.

This is because it is stopping at the ' chararcter (I'm guessing that it thinks the rest of the statement is being commented out) - how do I get round this so that it doesn't think that the rest of the statement is being commented out?

thanks

Adam
 
Old June 20th, 2004, 07:20 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you need to use the Replace() function and replace all single quotes with two single quotes.

Repalce(YourString,"'","'')

Stilll,if you are having any problems,
Response.Write(yourSQLStatement) and post it.
 
Old June 21st, 2004, 05:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Adam,

Can you post the code here, so as to find where you go wrong?

Cheers!

_________________________
-Vijay G
Strive for Perfection
 
Old June 21st, 2004, 06:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

sure

it's a stored procedure and this is the asp code I'm using for it:

set strSQL = con.execute("[up_insert_sale] '" & strSale & "' ,'" & strCondition & "' , '" & intPrice & "' , '" & strDetails & "' , '" & strName & "' , '" & strEmail & "' , '" & strLocation & "' , '" & strDateNow & "' , '" & Deleted & "'")

thanks
 
Old June 21st, 2004, 07:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Adam,

You are making mistake there by trying to set the result of con.execute() to strSQL.

It should be written this way.

Code:
set strSQL = "[up_insert_sale] '" & strSale & "' ,'" & strCondition & "' , '" & intPrice & "' , '" & strDetails & "' , '" & strName & "' , '" & strEmail & "' ,  '" & strLocation & "' ,  '" & strDateNow & "' , '" & Deleted & "'"
Response.write strSQL
response.end
con.execute(strSQL)
But I foresee that the code marked in RED should be causing problem, as you are trying to enclose intprice within quotes in first case. Not sure if Deleted is BIT type or INT type. Post details on these two COLUMN's DATA TYPES

And post the resulting SQL statement here. That should show what goes wrong.

Cheers!

_________________________
-Vijay G
Strive for Perfection
 
Old June 21st, 2004, 10:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

When I copy your code there and do a response.write I get this error:

Microsoft VBScript runtime error '800a01a8'

Object required: '[string: "[up_insert_sale] 'ad"]'

where ad is the text that I added in the text field.

intPrice is a varchar column and Deleted is bit.

thanks

Adam
 
Old June 21st, 2004, 10:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

That is because, you are missing "EXECUTE" word there.

It should be

strSQL = "Execute up_insert_sale .....

Remove SET keyword there.

If you say up_insert_sale is a stored proc.

Cheers!

_________________________
-Vijay G
Strive for Perfection
 
Old June 21st, 2004, 11:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

great, thanks Vijay
 
Old June 21st, 2004, 11:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Welcome! Actually I didnot notice that you were missing EXECUTE the previous time;).

Cheers!

_________________________
-Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Incorrect syntax near '.' meraj ADO.NET 6 February 27th, 2012 01:01 AM
Incorrect syntax near 'FULLTEXT'? Ron Howerton SQL Server 2005 5 August 30th, 2006 03:39 PM
Incorrect syntax near '!' sinapra Classic ASP Databases 8 August 25th, 2004 02:15 AM
Incorrect syntax near '`' Hez Classic ASP Databases 3 August 5th, 2004 08:13 AM
Incorrect SQL Syntax??! ckudrna Access ASP 1 June 5th, 2003 01:37 PM





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