Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Problems using variables in sql statement


Message #1 by "Marcus Miller" <Marcus.J.Miller@T...> on Mon, 15 Jan 2001 13:24:31 -0000
Hi all, 

got a small problem, dunno if any of u can help



I am querying a database based upon values retrieved from a form. The

problem part of the code is shown below where I am trying to pass a

variable to the SQL, the errors show the code and show the variable is

being passed yet I receive this error message.



This is the problem bit of code



sqlChoice15=sqlChoice15 & " AND

((CarRentalCompanies.Area2)='"&VarArea&"'));"



( i have checked this by creating a simple select statement with only this

condiditon )



And this is the error message i am getting



Technical Information (for support personnel)



Error Type:

HTTP 500.100 - Internal Server Error - ASP error

Internet Information Services





Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)

[Microsoft][ODBC Microsoft Access Driver] Extra ) in query expression

'((CarRentalCompanies.Area2)='Sutton_Coldfield'))'.

/BEGASP/htdoutput2.asp, line 248



Where 'Sutton_Coldfield' is the value passed showing that this is kinda

workin



Thanx in advance to all that read/reply



Marcus 

Message #2 by Imar Spaanjaars <Imar@S...> on Mon, 15 Jan 2001 15:10:31 +0100
Hi there,



Don't know about the rest of the query, but in the WHERE clause you use 3 

closing )'s while you only open 2.



'((CarRentalCompanies.Area2)='Sutton_Coldfield'))'.



Do a Response.Write(sqlChoice15) right before you open the recordset / 

execute the statement so you can checkout your query yourself. If there are 

still errors in the query, post the results of the 

Response.Write(sqlChoice15) to this list so we can have another look.



HtH



Imar





At 01:24 PM 1/15/2001 +0000, you wrote:

>Hi all,

>got a small problem, dunno if any of u can help

>

>I am querying a database based upon values retrieved from a form. The

>problem part of the code is shown below where I am trying to pass a

>variable to the SQL, the errors show the code and show the variable is

>being passed yet I receive this error message.

>

>This is the problem bit of code

>

>sqlChoice15=sqlChoice15 & " AND

>((CarRentalCompanies.Area2)='"&VarArea&"'));"

>

>( i have checked this by creating a simple select statement with only this

>condiditon )

>

>And this is the error message i am getting



Message #3 by Gregory_Griffiths@c... on Mon, 15 Jan 2001 13:51:50 +0000
If you read the error carefully the error concerns the number of 

brackets and if you count them - opening versus closing - you will find 

that you have one too many )'s.



> -----Original Message-----

> From: Marcus.J.Miller@T... [mailto:Marcus.J.Miller@T...]

> Sent: 15 January 2001 13:25

> To: asp_databases@p...

> Subject: [asp_databases] Problems using variables in sql statement

> 

> 

> Hi all, 

> got a small problem, dunno if any of u can help

> 

> I am querying a database based upon values retrieved from a form. The

> problem part of the code is shown below where I am trying to pass a

> variable to the SQL, the errors show the code and show the variable is

> being passed yet I receive this error message.

> 

> This is the problem bit of code

> 

> sqlChoice15=sqlChoice15 & " AND

> ((CarRentalCompanies.Area2)='"&VarArea&"'));"

> 

> ( i have checked this by creating a simple select statement 

> with only this

> condiditon )

> 

> And this is the error message i am getting

> 

> Technical Information (for support personnel)

> 

> Error Type:

> HTTP 500.100 - Internal Server Error - ASP error

> Internet Information Services

> 

> 

> Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)

> [Microsoft][ODBC Microsoft Access Driver] Extra ) in query expression

> '((CarRentalCompanies.Area2)='Sutton_Coldfield'))'.

> /BEGASP/htdoutput2.asp, line 248

> 

> Where 'Sutton_Coldfield' is the value passed showing that 

> this is kinda

> workin

> 

> Thanx in advance to all that read/reply

> 

> Marcus 

> 

Message #4 by Remco Vermeer <Remco@c...> on Mon, 15 Jan 2001 15:06:51 +0100
Looks like you are using one ")" too much



Or it should be: "WHERE (((table.field1) = "bla" ) AND

((CarRentalCompanies.Area2)='" & VarArea & "'));"



Regards,



Remco



-----Original Message-----

From: Marcus Miller [mailto:Marcus.J.Miller@T...]

Sent: Monday, January 15, 2001 2:25 PM

To: ASP Databases

Subject: [asp_databases] Problems using variables in sql statement





Hi all, 

got a small problem, dunno if any of u can help



I am querying a database based upon values retrieved from a form. The

problem part of the code is shown below where I am trying to pass a

variable to the SQL, the errors show the code and show the variable is

being passed yet I receive this error message.



This is the problem bit of code



sqlChoice15=sqlChoice15 & " AND

((CarRentalCompanies.Area2)='"&VarArea&"'));"



( i have checked this by creating a simple select statement with only this

condiditon )



And this is the error message i am getting



Technical Information (for support personnel)



Error Type:

HTTP 500.100 - Internal Server Error - ASP error

Internet Information Services





Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)

[Microsoft][ODBC Microsoft Access Driver] Extra ) in query expression

'((CarRentalCompanies.Area2)='Sutton_Coldfield'))'.

/BEGASP/htdoutput2.asp, line 248



Where 'Sutton_Coldfield' is the value passed showing that this is kinda

workin



Thanx in advance to all that read/reply



Marcus 



Message #5 by "Wally Burfine" <oopconsultant@h...> on Mon, 15 Jan 2001 15:37:50 -0000
The question is, where is the rest of the query?





>From: "Marcus Miller" <Marcus.J.Miller@T...>

>Reply-To: "ASP Databases" <asp_databases@p...>

>To: "ASP Databases" <asp_databases@p...>

>Subject: [asp_databases] Problems using variables in sql statement

>Date: Mon, 15 Jan 2001 13:24:31 -0000

>

>Hi all,

>got a small problem, dunno if any of u can help

>

>I am querying a database based upon values retrieved from a form. The

>problem part of the code is shown below where I am trying to pass a

>variable to the SQL, the errors show the code and show the variable is

>being passed yet I receive this error message.

>

>This is the problem bit of code

>

>sqlChoice15=sqlChoice15 & " AND

>((CarRentalCompanies.Area2)='"&VarArea&"'));"

>

>( i have checked this by creating a simple select statement with only this

>condiditon )

>

>And this is the error message i am getting

>

>Technical Information (for support personnel)

>

>Error Type:

>HTTP 500.100 - Internal Server Error - ASP error

>Internet Information Services

>

>

>Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)

>[Microsoft][ODBC Microsoft Access Driver] Extra ) in query expression

>'((CarRentalCompanies.Area2)='Sutton_Coldfield'))'.

>/BEGASP/htdoutput2.asp, line 248

>

>Where 'Sutton_Coldfield' is the value passed showing that this is kinda

>workin

>

>Thanx in advance to all that read/reply

>

>Marcus


  Return to Index