Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameterized Query

Status
Not open for further replies.

obryant32

IS-IT--Management
Feb 20, 2003
66
US
Hi...I'm begging for help.

What I'm trying to do is create a website template that gets populated based on a unique parameter ID in the URL.
Using that value "1" that I get from the request.querystring I want to then be able to connect to a database and pull out specific data linked to that ID. I'm trying to do that but I can't seem to figure out what's wrong. I've created an aspfunc.asp page where the DB connection query is being written and referenced to in every page. My code on that page looks something like this...
<%

Dim objConn
Dim objRecordSet
Dim query
Dim ID
ID = request.queryString("ID")

Set objConn = Server.CreateObject("ADODB.Connection")
Set objRecordSet = Server.CreateObject("ADODB.Recordset")

query = "Select CustomerName from Customer"
query = query & "WHERE UnitID = ID"

objLFConn.Open "Provider=SQLOLEDB; Data Source = DATASERVER; Initial Catalog = DATABASE; User Id = user; Password= pwd"
objRecordSet.Open query, objConn


DO While Not objRecprdSet.EOF

LOOP

Set objConn = Nothing
Set objRecordSet = Nothing
query = ""
%>


What in the world am I missing?
Thanks
Matt
 
If you try an response.write query you would see:

Select CustomerName from CustomerWHERE UnitID = ID

Change your second line to query = query & " WHERE UnitID = " & ID


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top