Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 22nd, 2003, 03:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well your hyperlink just has to point to an asp page that runs the sql query and displays the results. Here's a crude example:
Code:
your hyperlink would be something like this:
<a href="viewAllCustomers.asp">view all customers</a>

then viewAllCustomers.asp should contain something like this:
<%
...
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "connection string goes here"
Set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from customerinfo", conn
Do While Not rs.EOF
   ' this just writes the data out to the page
   ' you can add any HTML you like to make the
   ' page appear how you want
   Response.Write(rs("Field1").Value)
   Response.Write(rs("Field2").Value)
   Response.Write("etc...")
   rs.MoveNext
Loop

rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
%>
hth
Phil
 
Old August 22nd, 2003, 06:00 AM
Authorized User
 
Join Date: Aug 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default

Hello Mr.Phil

             Thankz for Your information, I would like to know whether I can pass any parameters through the hyperlink.i.e. if I want the query "select * from customerinfo where customername='tom' "
I want to send the customername =tom through the hyperlink.How to do it?
 
Old August 22nd, 2003, 07:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

OK, just change your hyperlink to
Code:
<a href="viewAllCustomers.asp?customername=tom">view tom</a>
then you can pick it up in viewAllCustomers.asp using
Code:
sCustomerName=Request.QueryString("customername")
...
rs.Open "Select * from customerinfo where customername='" & Replace(sCustomerName, "'", "''") & "'", conn
...
but this opens up a can of worms, really. You have to be very careful
when using direct SQL which embeds information passed from the client. Do a search on "SQL injection attacks" to see what you could be letting yourself in for.

If customername contains a ' (e.g. customername=o'reilly) then you have to replace the ' with a '' as shown above.

hth
Phil
 
Old August 25th, 2003, 12:27 AM
Authorized User
 
Join Date: Aug 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default

Hello mr.phil

  When I execute the query " select * from customer where name='bush' " , and there are no records matching this condition then I would like to have a message saying "no records available" .How do I do this?

Thank You
Praveen

 
Old August 25th, 2003, 05:45 AM
Authorized User
 
Join Date: Aug 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default


Hello Mr.phil

         I have used three hyper reference statements to pass the parameter "servername", now
I have also saved the value of the parameter "servername" in a variable called "temp" .


Now If I replace the statement :
<a href ="http:\\localhost\project1\disphard.asp?servernam e=wiproecmx2">HARDWARE
CONFIGURATION </a>

With the Statement:

<a href ="http:\\localhost\project1\disphard.asp?<%=temp%> ">HARDWARE CONFIGURATION </a>

Iam getting a VB compilation Error.

My query is that : What is the Error in above statement? and How do I pass the value of variable
"temp" using the Link ?

================================================== ========================
This Is The Program:
================================================== ===========================
<html>
<title>Server Docket</title>
<head><b><center>
<%
serverName=Request.QueryString("servername")
response.write (servername)
dim temp
 temp=request.querystring("servername")

%></center>
</b></head>
<body>

<PRE><CENTER>

<a href ="http:\\localhost\project1\disphard.asp?servernam e=wiproecmx2">HARDWARE CONFIGURATION </a><br>

<a href ="http:\\localhost\project1\dispsoft.asp?servernam e=wiproecmx2">SOFTWARE CONFIGURATION </a><br>

<a href ="http:\\localhost\project1\displaygen.asp?servern ame=wiproecmx2">GENERAL DETAILS </a><br>


%>


</body>
</html>
================================================== =====================

How do I replace "servername=wiproecmx2" with <%=temp%> ???

Thank You


 
Old August 25th, 2003, 06:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

Try this:

Code:
<a href ="http:\\localhost\project1\disphard.asp?servername=<%=temp%>">HARDWARE CONFIGURATION</a>
... and you might want to flip your slashes ...

Code:
<a href ="http://localhost/project1/disphard.asp?servername=<%=temp%>">HARDWARE CONFIGURATION</a>
 
Old August 26th, 2003, 02:42 AM
Authorized User
 
Join Date: Aug 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default

Hi

    How can I flood a combo box (drop down box) with an entire column of a table. ex : if I want all the names of customers from table customerinfo in the drop down box how do i do it?

Thank You

Praveen

 
Old August 26th, 2003, 10:29 PM
Authorized User
 
Join Date: Aug 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default

Hi
     If I execute a query "select * from customerinfo where name= 'steve' " and if there are no queries matching the criteria , then I would like to have a "no records available " message displayed. How do I do It?

 
Old August 27th, 2003, 02:40 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by spraveens
 Hi
     If I execute a query "select * from customerinfo where name= 'steve' " and if there are no queries matching the criteria , then I would like to have a "no records available " message displayed. How do I do It?
After you execute the query and get a recordset back, just test for an end-of-file marker, like this
Code:
If rsName.EOF Then
  ' no records
Else
  ' records exist, rsName points to the first one
End If
hth
Phil
 
Old August 27th, 2003, 05:49 AM
Authorized User
 
Join Date: Aug 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default

Hi Mr.phil

How do I display a messagebox to confirm the deletion of a record?
When i click delete , a message box should be displayed to confirm my deletion .PLease give code :)

regards
Praveen...






Similar Threads
Thread Thread Starter Forum Replies Last Post
asp/Access recordset navigation query murshed Classic ASP Databases 1 April 10th, 2008 01:43 PM
Clone DAO Recordset into ADO Recordset kamrans74 VB How-To 0 March 6th, 2007 11:57 AM
Query from Recordset into another Recordset kamrans74 Pro VB Databases 5 March 5th, 2007 04:17 PM
Convert ADO recordset to DAO recordset andrew_taft Access 1 May 5th, 2004 02:31 PM
code to copy a query recordset to a file Ivan Access VBA 9 October 31st, 2003 06:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.