View Full Version : Asp and databases
hey im new to the ASP Scene and just need a little help working on a script so it reads a table and also one field (eg dataID) and if the field equals a number it will show all the data in that row. and also i need the page to work like this..
www.whatever.com/data.asp?DataID=(number here)
thanks for any help u can give me.
You need to write a new SQL statement in the page data.asp
I take it you already have a Record set & SQL statement?
If yes, then you need to declare a variable, and assign it the value of querystring DataID, like this:
Dim RequestedID
RequestedID = Request.QueryString("DataID")
You need to do that before your SQL statement. Then change your SQL statement to:
"SELECT * FROM TableName WHERE DataID = " & RequestedID & ""
Haven't tested, but should work.
Gurrutello
06-20-03, 08:45 PM
why dont show your code??
it wil be easyer
saludos
edshere@macventure.com
06-23-03, 08:22 PM
'Grab desired variable from url
idval = request.querystring("id")
'Specify driver and path.
strconn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("DB_NAME.mdb")
'Create ado object
set conn = server.createobject("adodb.connection")
'Instruct what to open
conn.open strconn
'SQL query
sql = "Select * from TABLE_NAME where FIELD_NAME = "&idval&""
'Open connection and execute query as recordset
set rs = conn.execute(sql)
'Write Data to the page
response.write rs("FIELD_NAME_1")
response.write rs("FIELD_NAME_2")
'Don't forget to close the connection
'Close connection
conn.close
set conn = nothing
edshere@macventure.com
06-23-03, 08:27 PM
'ooops forgot something.
'Let me try this again.
'Grab desired variable from url
idval = request.querystring("id")
'Specify driver and path.
strconn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("DB_NAME.mdb")
'Create ado object
set conn = server.createobject("adodb.connection")
'Instruct what to open
conn.open strconn
'SQL query
sql = "Select * from TABLE_NAME where FIELD_NAME = "&idval&""
'Open connection and execute query as recordset
set rs = conn.execute(sql)
'Check to see if a record exists.
if rs.eof then '****************************
response.write "Could not find that record. Please try again."
'or
'response.redirect "where_ever.asp"
else '****************************
'Write Data to the page
response.write rs("FIELD_NAME_1")
response.write rs("FIELD_NAME_2")
End if '****************************
'Close connection
conn.close
set conn = nothing
Thankz this is really helpfull, problem is the website im building is going to take months for me to complete, all because there is only one person building, coding, debuging and designing the whole site and that one person is me. so thanks for helping me with my problem, im going to try that now
Ph33r
Gurrutello
06-26-03, 05:36 PM
the code seems ok
what its the error you get??
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.