Cold Fusion + SQL, Help if you would be so kind

Associate
Joined
12 Mar 2005
Posts
2,021
Location
Scotland
Hey having some trubble getting my website to work. (:( boooo i hear you all say)

Iv got ...session.AccessLevel = CustID... when the cust logs onto the website, which works fine, i can output the session.AccessLevel on any other page after that. :)

What i need is to display cust details where session.AccessLevel = CustID:

SELECT *
FROM Cust
WHERE session.Accesslevel = CustID

error i get:

Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]The multi-part identifier "session.AccessLevel" could not be bound.


I also tried 'session.AccessLevel' = CustID

error:

Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]Conversion failed when converting the varchar value 'session.AccessLevel' to data type int.


How can i compair AccessLevel and CustID in the SQL statment? :confused:

Cheers :D
 
Last edited:
The 2nd error is being thrown becasue you are comparing a varchar (putting session.AccessLevel in quotes defines it as a string) with an int.

I have absolutely no knowledge of Cold Fusion (Personally if you are starting out Id recommend learning either ASP, preferably .NET, or PHP) but it seems strange to be passing what seems to be a session variable into a SQL statement.

Do you not need to build a string containing the value from the session eg.

string sql = " SELECT * FROM Cust WHERE CUSTID = " + session.Accesslevel

Then execute the string sql. Either that or pass in the access level as a parameter?
 
Thanks for the sugestion. Managed to work it out...eventualy

needed to be:

CustID = #session.AccessLevel#

Lest thats over with now, im sure ill have lots of questions for you all soon :p

Cheers
 
Good to know its sorted, always feel a little warmth inside when you solve your own problems :)

Ive not seen much talk of Cold Fusion on here, although thats not to say that no one has developed using it you might be better off finding a more dedicated forum for future questions or problems.
 
Back
Top Bottom