Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: When is a variable not a variable?


Message #1 by Jean Halstad <J_Halstad@S...> on Wed, 23 May 2001 16:51:38 +0100
Am getting more out of my depth here.



This is the error message:

The name 'introom' is illegal in this context. Only constants, constant

expressions, or variables allowed here. Column names are illegal. 



I am not sure why SQL thinks this is not a variable. Roomid is a foreign key

field in bookings table, which references the rooms table.

I queried two columns in the rooms table, to get the roomid. I put the

roomid into a variable (introom). I am now trying to insert this variable

into the roomid field of the bookings table.



 If I do response.write introom I get a number, which is correct.



strSQL = "Insert into bookings (roomid, bookdate, starttime, endtime,

bookedby, purpose)"  &_

"values (intRoom, datBookDate, strStartTime, strEndTime, strBookedBy,

strPurpose)"



Message #2 by "Peter Foti (PeterF)" <PeterF@S...> on Wed, 23 May 2001 12:07:35 -0400
I don't know if this has anything to do with the problem you are 

seeing,

but you should add a space at the end of the first line of your SQL

string, before the "values".  Like so:



strSQL =3D "Insert into bookings (roomid, bookdate, starttime, endtime,

bookedby, purpose) "  &_

"values (intRoom, datBookDate, strStartTime, strEndTime, strBookedBy,

strPurpose)"



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

> From: Jean Halstad [mailto:J_Halstad@S...]

> Sent: Wednesday, May 23, 2001 11:52 AM

> To: ASP Databases

> Subject: [asp_databases] When is a variable not a variable?

>

>

> Am getting more out of my depth here.

>

> This is the error message:

> The name 'introom' is illegal in this context. Only

> constants, constant

> expressions, or variables allowed here. Column names are illegal.

>

> I am not sure why SQL thinks this is not a variable. Roomid

> is a foreign key

> field in bookings table, which references the rooms table.

> I queried two columns in the rooms table, to get the roomid. I put 

the

> roomid into a variable (introom). I am now trying to insert

> this variable

> into the roomid field of the bookings table.

>

>  If I do response.write introom I get a number, which is correct.

>

> strSQL =3D "Insert into bookings (roomid, bookdate, starttime, 

endtime,

> bookedby, purpose)"  &_

> "values (intRoom, datBookDate, strStartTime, strEndTime, strBookedBy,

> strPurpose)"

>

>

Message #3 by Hal Levy <hal.levy@s...> on Wed, 23 May 2001 12:15:33 -0400
Jean,



strSQL =3D "Insert into bookings (roomid, bookdate, starttime, endtime,

bookedby, purpose)"  &_

"values (intRoom, datBookDate, strStartTime, strEndTime, strBookedBy,

strPurpose)"



says make roomid =3D introom   not roomid =3D value of introom

You should do this:



strSQL =3D "Insert into bookings (roomid, bookdate, starttime, endtime,

bookedby, purpose) "  &_

"values (" & intRoom & ", " & datBookDate & ", '" & strStartTime & "', 

'" &

strEndTime & "', '" & strBookedBy & "', '" & strPurpose & "')"





Hal Levy

StarMedia Network, Inc.

Intranet Development Manager



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

From: Jean Halstad [mailto:J_Halstad@S...]

Sent: Wednesday, May 23, 2001 11:52 AM

To: ASP Databases

Subject: [asp_databases] When is a variable not a variable?





Am getting more out of my depth here.



This is the error message:

The name 'introom' is illegal in this context. Only constants, constant

expressions, or variables allowed here. Column names are illegal.



I am not sure why SQL thinks this is not a variable. Roomid is a 

foreign key

field in bookings table, which references the rooms table.

I queried two columns in the rooms table, to get the roomid. I put the

roomid into a variable (introom). I am now trying to insert this 

variable

into the roomid field of the bookings table.



 If I do response.write introom I get a number, which is correct.



strSQL =3D "Insert into bookings (roomid, bookdate, starttime, endtime,

bookedby, purpose)"  &_

"values (intRoom, datBookDate, strStartTime, strEndTime, strBookedBy,

strPurpose)"



Message #4 by Kyle Burns <kburns@c...> on Sun, 27 May 2001 18:02:32 -0500
The Values portion of your statement should be:

"values (" & intRoom & ", " & ...



The problem is that you are using the word intRoom instead of the value

contained in the VBScript variable intRoom.  The best way to 

troubleshoot

this type of problem is to Response.Write strSQL and then copy the 

resulting

SQL to debug in the DBMS that you are using.







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

>> From: Jean Halstad [mailto:J_Halstad@S...]

>> Sent: Wednesday, May 23, 2001 10:52 AM

>> To: ASP Databases

>> Subject: [asp_databases] When is a variable not a variable?

>>

>>

>> Am getting more out of my depth here.

>>

>> This is the error message:

>> The name 'introom' is illegal in this context. Only

>> constants, constant

>> expressions, or variables allowed here. Column names are illegal.

>>

>> I am not sure why SQL thinks this is not a variable. Roomid

>> is a foreign key

>> field in bookings table, which references the rooms table.

>> I queried two columns in the rooms table, to get the roomid.

>> I put the

>> roomid into a variable (introom). I am now trying to insert

>> this variable

>> into the roomid field of the bookings table.

>>

>>  If I do response.write introom I get a number, which is correct.

>>

>> strSQL =3D "Insert into bookings (roomid, bookdate, starttime, 

endtime,

>> bookedby, purpose)"  &_

>> "values (intRoom, datBookDate, strStartTime, strEndTime, 

strBookedBy,

>> strPurpose)"

  Return to Index