Retrieving a field from a SQL and using as variable (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


JohnH -> Retrieving a field from a SQL and using as variable (5/9/2008 10:36:24)

I have simple query of a SQL database, I want to be able to pull a field from the database and then use it elsewhere in my ASP page. I attempted this using the code below but I don't get anything back when I use the variable.

<%
Dim req_no
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=server;UID=user;PWD=password;DATABASE=dbase"
Set rs = Server.CreateObject("ADODB.Recordset")

SQL =	"SELECT REQUISITION_NO FROM REQUISITION_MASTER WHERE CREATION_DATE ='" & (CREATION_DATE) & "' AND CREATION_TIME='" & CREATION_TIME & "'"

rs.open SQL, conn

req_no = rs("REQUISITION_NO")

conn.close
Set rs = Nothing
Set conn = Nothing
%>


I am referencing the viariable by using

<%=req_no%>


Many thanks,

John




BeTheBall -> RE: Retrieving a field from a SQL and using as variable (5/9/2008 12:10:20)

The code looks correct. Are you sure there is a record that meets the criteria you are using in your query?




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
6.298828E-02