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 June 28th, 2004, 11:41 AM
Authorized User
 
Join Date: Jun 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retrieving a ticket number from spl database

I am able to connect to sql databae and it's retrieving all the tickets. Is there a way to set
a query string to display the current ticket number that was generated in the database.


Here's the code


str="SELECT Ticket_Number FROM Escalation_Forms"
rs.open str
While not rs.EOF
Response.Write rs("Ticket_Number") & "<BR>"
rs.MoveNext



Thank you



 
Old June 28th, 2004, 12:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

Where is the connection to the database? Was that left out of your code post?

Brian
 
Old June 28th, 2004, 12:51 PM
Authorized User
 
Join Date: Jun 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It was left out! here is the rest of it !

<%

Dim con, rs, str

set con=Server.CreateObject("ADODB.CONNECTION")

con.Open "Provider=sqloledb;Data Source=Flmirsql02;Initial Catalog=Source_Forms;User Id=Source_Forms_User;Password=password;"


str="SELECT Ticket_Number FROM Escalation_Forms"



set rs = con.execute(strSql)

if rs.eof
    then
    Response.write("No records returned")

end if

do Until rs.eof

Response.write("<a href=Confirmation.asp?tnum=" & rs("Ticket_Number") & ">" & rs("Ticket_Number") & "</a><br>")
   rs.MoveNext
   loop


rs.Close

con.Close

Set rs = Nothing

Set con =Nothing
%>

Your help is greatly appreaciated!
thank you

 
Old June 28th, 2004, 12:54 PM
Authorized User
 
Join Date: Jun 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am getting the following error!


Microsoft VBScript compilation error '800a03f9'

Expected 'Then'

/forms/Confirmation.asp, line 35

if rs.eof
---------^


 
Old June 28th, 2004, 01:16 PM
Authorized User
 
Join Date: Jun 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is the original code! I trying to access the current ticket number within the database that was generated!

Thanks


<%

Dim con, rs, str

set con=Server.CreateObject("ADODB.CONNECTION")

con.Open "Provider=sqloledb;Data Source=Flmirsql02;Initial Catalog=Source_Forms;User Id=Source_Forms_User;Password=password;"

set rs=server.CreateObject("ADODB.RECORDSET")

rs.ActiveConnection=con

str="SELECT Ticket_Number FROM Escalation_Forms"


rs.open str

While not rs.EOF

Response.Write rs("Ticket_Number") & "<BR>"

rs.MoveNext

Wend


rs.Close

con.Close

Set rs = Nothing

Set con =Nothing
%>

 
Old June 28th, 2004, 02:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

The error for:

if rs.eof
    then
    Response.write("No records returned")

end if

Is because it needs to be

if rs.eof then

or

if rs.eof _
then

Brian
 
Old June 28th, 2004, 02:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

Are you still having problems? What is your final code that you are using if you are?

Brian
 
Old June 28th, 2004, 03:24 PM
Authorized User
 
Join Date: Jun 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Microsoft OLE DB Provider for SQL Server error '80040e0c'

Command text was not set for the command object.

/forms/Confirmation.asp, line 32


Pointint this code:
set rs = con.execute(strSql)




 
Old June 28th, 2004, 08:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Calibus,

That denotes that you are missing this before the line that shows error.

Code:
str="SELECT Ticket_Number FROM Escalation_Forms"

set rs = con.execute(strSql)
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old June 29th, 2004, 07:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

In this post, you are using a variable for the SQL that isn't being set to anything. you set the SQL to str but use strSQL (which has an empty string):

str="SELECT Ticket_Number FROM Escalation_Forms"
set rs = con.execute(strSql)

Should be:

str="SELECT Ticket_Number FROM Escalation_Forms"
set rs = con.execute(str)

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Building my own ticket tracker cf2006 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 August 31st, 2006 11:04 AM
retrieving from database... URGENT!!! roryosullivan JSP Basics 1 March 9th, 2005 03:11 PM
NEED HELP! retrieving from database nvillare .NET Web Services 5 October 22nd, 2004 12:37 AM
problem retrieving from database rajuru Beginning PHP 2 October 8th, 2004 12:34 PM
NEED HELP! retrieving from database nvillare ADO.NET 1 December 2nd, 2003 10:31 AM





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