dashifire
asked on
Need to do an SQL select statement in Classic ASP for a variable
I need to replace a session variable with the results of an SQL statement
that statement essentially is:
My code is currently:
However I am getting an error at "as"
I tried doing paypalnew=thestring but it put it as straight text instead of being a SQL Statement.
This is my first real programming project, so i know that i am probably just missing some basics, but finding resources for classic ASP is very tough :/
that statement essentially is:
SELECT EmailAddress FROM USERS WHERE UserID=session(userid)"
My code is currently:
dim paypalnew as string = "SELECT EmailAddress FROM USERS WHERE UserID='"&session(userid)&"'"
session("paypalemail")=paypalnew
However I am getting an error at "as"
I tried doing paypalnew=thestring but it put it as straight text instead of being a SQL Statement.
This is my first real programming project, so i know that i am probably just missing some basics, but finding resources for classic ASP is very tough :/
ASKER
that's what i need to know how to do, get the variable
Here is a good asp resource : http://www.asptutorial.inf o/
Here is a resource for learning about how to use ADO for connecting to databases using asp :
http://www.w3schools.com/a do/default .asp
Here is a resource for learning about how to use ADO for connecting to databases using asp :
http://www.w3schools.com/a
What kind of database are you using?
ASKER
MS SQL
ASKER
sweet resources btw.
Another nice tutorial here on how to use ado with asp to connect to a sql server database :
http://aspalliance.com/655 _Basic_ADO _and_SQL_T utorial.1
http://aspalliance.com/655
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks when I get a shot next I will try this. I do have option explicit on though, not my idea, but working with it anyway.
Then just make sure to dim all your variables first before you use them.
ASKER
That was perfect, the tutorials are terrific, but they don't tell me what is a variable and i was getting confused. I got it up and running now, so it is all good! Thanks Guys!
Dim myVariableName
and to set a value to it :
Set myVariableName = 'whatever'
so your code would become :
Open in new window
However you code will not achieve you desired result (as I understand it) of populating the session variable with the result of the query it will just populate it with the text.