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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query String, Link, And Browser.....

Status
Not open for further replies.

CDNJungler

Programmer
Jul 16, 2002
11
CA
I have this little problem I was hoping someone could help me out with. I have to make a link that when clicked on, will pass values through the query string and display a dynamically generated report in a new browser window. I don't right now know how to use the query string nor how to write the code to do this. Any suggestions will be of great help to me. Thanks
 
First you must choose how you want to pull the data, you can pull it by any column_name in the database, but you should have it unique.

So if you have a ID number for the record you can pull it that way, which is recommended because the database has better performace on numbers then on text and an ID number can be set to unique so there is no duplicates.

On your first page you have your link

Code:
<a href=&quot;secondpage.asp?ID=1&quot;>Record 1</a>

Then on your second page you will do a select statement:

Code:
<% 
Dim ConnString, strSQL, RecordID
 
ConnString = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & Server.MapPath(&quot;database.mdb&quot;) 
 
' ADO connection class 
set my_conn= Server.CreateObject(&quot;ADODB.Connection&quot;) 
 
' rs recordset will contain all fields in db such as userID, name, email  
set rs = Server.CreateObject(&quot;ADODB.RecordSet&quot;) 
 
' Connect ADO & open database 
my_conn.Open ConnString 
 
  
RecordID = Request.QueryString(&quot;ID&quot;) '# Request the ID in the querystring 

If isNumeric(RecordID) = True then

strSQL = &quot;SELECT * FROM table_name WHERE ID=&quot; & RecordID
  
Else
Response.Write &quot;Invalid Id number&quot;
Response.End '# Stop reading ASP
End if
 
' Execute SQL statement 
rs = my_conn.Execute(strSQL) 
  

'# Then to write a data thats in the db you just do this:

Response.Write &quot;column_name= &quot; & rs(&quot;column_name&quot;)

'# (change column name to one in the db such as ID or whatever.. 

 
my_conn.close ' Close database connection 
set my_conn = nothing 'obj variable released 
 
%>


If you want further information on setting up your database, you can visit my site where there are a few tutorials on the subject:


- Jason
jason@vzio.com
Web Developer


www.vzio.com
star.gif
/ [wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top