navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Retrieving a field from a SQL and using as variable

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Retrieving a field from a SQL and using as variable
Page: [1]
 
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.

(in reply to JohnH)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Retrieving a field from a SQL and using as variable
Page: [1]
Jump to: 1





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