 |
| 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
|
|
|
|

June 28th, 2004, 11:41 AM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 28th, 2004, 12:23 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hello,
Where is the connection to the database? Was that left out of your code post?
Brian
|
|

June 28th, 2004, 12:51 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 28th, 2004, 12:54 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am getting the following error!
Microsoft VBScript compilation error '800a03f9'
Expected 'Then'
/forms/Confirmation.asp, line 35
if rs.eof
---------^
|
|

June 28th, 2004, 01:16 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
%>
|
|

June 28th, 2004, 02:58 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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
|
|

June 28th, 2004, 02:59 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hello,
Are you still having problems? What is your final code that you are using if you are?
Brian
|
|

June 28th, 2004, 03:24 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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)
|
|

June 28th, 2004, 08:44 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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 
|
|

June 29th, 2004, 07:55 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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
|
|
 |