|
| |
|
|
JohnH
Posts: 43 Joined: 12/1/2004 Status: offline
|
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
Posts: 6271 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
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?
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|