Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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 July 19th, 2004, 11:01 AM
Authorized User
 
Join Date: Jun 2004
Location: miami, fl, USA.
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error Line 1: Incorrect syntax near '='.

I need some help understanding this error!

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

Line 1: Incorrect syntax near '='.

/forms/Results.asp, line 59

Line 59 is :rs.open strSql, ObjConn, 3, 3

And when I put an = sign I get the following error:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/forms/Results.asp, line 59

rs.open = strSql, ObjConn, 3, 3


Thank you


 
Old July 19th, 2004, 11:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

Look at error messages
The first
Quote:
quote:
Microsoft OLE DB Provider for SQL Server error '80040e14'

Line 1: Incorrect syntax near '='.
tells you that you have a syntax error in your SQL-code (in line 1).

The second
Quote:
quote:
/forms/Results.asp, line 59
tells you where in your ASP-code this occured.

Your problem is not in line 59 in the ASP-file, it's in the SQL you send to SQL Server (near the = sign).

Insert these lines just before line 59:
Code:
response.write strSql
response.end
...and show us your SQL.

 
Old July 19th, 2004, 12:57 PM
Authorized User
 
Join Date: Jun 2004
Location: miami, fl, USA.
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here's my sql

<%
Dim TicketNum, rs, ObjConn, Conn



TicketNum = Request.QueryString("Ticket_Number")

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

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


Set rs = Server.CreateObject("ADODB.Recordset")

Dim strSQL

strSQL = "SELECT Status, First_Name, Last_Name, Phone_Number, Wip_Com FROM Escalation_Forms WHERE Ticket_Number = " & TicketNum
response.write strSql
response.end

rs.open strSql, ObjConn, 3, 3


if rs.eof then

   Response.write("No data was returned for ticket number: " & TicketNum)

else


   Status = rs("Status")= Request.Form("Status")
   First_Name = rs("First_Name")
   Last_Name = rs("Last_Name")
   Phone_Number = rs("Phone_Number")
   Wip_Com = rs("Wip_Com")

end if

ObjConn.Close
Set ObjConn = Nothing


 
Old July 19th, 2004, 01:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

That is your ASP-code - if you browse the page (with the response.write strSql), it will show you the SQL-code you are sending to MSSQL.

What is the datatype of Ticket_Number?

 
Old July 19th, 2004, 01:30 PM
Authorized User
 
Join Date: Jun 2004
Location: miami, fl, USA.
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The data type for Ticket_Number is Integer! Maybe I going the wrong way about this. I have table that shows ticket numbers and customer's info as a link. Within the link I have Variable call TicketNum. I am trying to call TicketNum and display some information about that ticket number and give the user the capability to update or give feedback to the end user.

Any help or guidiance is greatly appreciated.

Thank you!


 
Old July 19th, 2004, 03:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

Try this:
Code:
<%
Dim TicketNum, rs, ObjConn, Conn

TicketNum = Request.QueryString("Ticket_Number")
if IsNumeric(TicketNum) = true then
    TicketNum = CInt(TicketNum)
else
    response.redirect("URL of the table that shows ticket numbers and customer's info as a link")
end if

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

[...]
Btw: You still haven't shown me your SQL-code...
Open the page in a browser and check the output of response.write strSQL

 
Old July 19th, 2004, 03:54 PM
Authorized User
 
Join Date: Jun 2004
Location: miami, fl, USA.
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is the only part of asp I am having problem understanding I creating a ticket system and everything went well except this part. It's asking me to declare the field I am trying to retrieve when I don't believe I should. I am trying to accomplish something similar:
http://www.asp101.com/samples/db_edit.asp

Now it tell the following:
No data was returned for ticket number: 0 Status:
Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'Status'

/forms/Results.asp, line 93

Code:
<%
Dim TicketNum, rs, ObjConn, Conn

TicketNum = Request.QueryString("Ticket_Number")

if IsNumeric(TicketNum) = true then
    TicketNum = CInt(TicketNum)
else

response.redirect("<a href='Results.asp?TicketNum=" & objRS("Ticket_Number") & "'>" & objRS("Ticket_Number")& "</a></td>")

end if

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

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


Set rs = Server.CreateObject("ADODB.Recordset")

Dim strSQL

strSQL = "SELECT First_Name, Last_Name FROM Escalation_Forms WHERE Ticket_Number = " & TicketNum


rs.open strSql, ObjConn, 3, 3

if rs.eof then

Response.write("No data was returned for ticket number: " & TicketNum)

else


Status = rs("Status")
First_Name = rs("First_Name")
Last_Name = rs("Last_Name")
Phone_Number = rs("Phone_Number")
Wip_Com = rs("Wip_Com")

end if

ObjConn.Close
Set ObjConn = Nothing


%>

<table>
<tr>
    
[u] <td>Status:</td><td><input type="text" name="Status" value="<%=Status%>">[</u>t] <td>First Name:</td><td><input type="text" name="First_Name" value="<%=First_Name%>">
     <td>Last Name:</td><td><input type="text" name="Last_Name" value="<%=Last_Name%>">
     <td>Phone Number:</td><td><input type="text" name="Phone_Number" value="<%=Phone_Number%>">

    
</tr>
</table>
 
Old July 19th, 2004, 04:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

Looks like your db-things are working now, but that no data exist on TicketNum 0.

Change your code to this, to stop it running when db returns no results...

Code:
[...]
if rs.eof then

   Response.write("No data was returned for ticket number: " & TicketNum)
   Response.end
else


   Status = rs("Status")
[...]
 
Old July 20th, 2004, 08:41 AM
Authorized User
 
Join Date: Jun 2004
Location: miami, fl, USA.
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Would you happen to know why it's displaying(" No data was returned for ticket number: 0")
For some reason it not picking the string("TicketNum") from the previous page. Can you look over this code? I would like to get a second opinion. This is the table that displays all ticket number as link.

Code:

  <%@ Language=VBScript %>
<%Option Explicit %>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>

<div align="center">
  <center>
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000" width="985" height="50" id="table1" bgcolor="#000000">
    <tr>
      <td width="983" height="50" align="center">
    <img border="0" src="LogoMasthead.gif" align="left" width="150" height="45"><img border="0" src="header_level3.jpg" width="828" height="48"></td>
    </tr>
  </table>
  </center>
</div>

<p>&nbsp;</p>
        <p align="center">

        Access Database
<p>&nbsp;</p>
<p>

<%
Dim objConn, objRS, SQLstring

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

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




' Create recordset and retrieve values using the open connection

Set objRS = Server.CreateObject("ADODB.Recordset")


SQLstring = "SELECT Top 5 * FROM Escalation_Forms WHERE Escalation_Type='"& Replace(Request.QueryString("Escalation_Type"), "'", "''") &"'"
objRS.Open SQLstring, objConn, 0, 1

    ' Show selected record




        %>
        <div align="center">
        <table border="2">
            <tr>
                <th bgcolor="#000000"><strong>Ticket Number</strong></th>
                <th bgcolor="#000000"><strong>Escalation Type</strong></th>
                <th bgcolor="#000000"><strong>First Name</strong></th>
                <th bgcolor="#000000"><strong>Last Name</strong></th>
                <th bgcolor="#000000"><strong>Account Number</strong></th>
                <th bgcolor="#000000"><strong>Phone Number</strong></th>
                <th bgcolor="#000000"><strong>CAE Name</strong></th>
                <th bgcolor="#000000"><strong>Customer Comment</strong></th>
                <th bgcolor="#000000"><strong>Status</strong></th>
                <th bgcolor="#000000"><strong>Feed Back</strong></th>


                </tr>




            <%
            Do Until objRS.EOF

                Response.Write ("<tr>")

                   Response.Write("<td><a href='Results.asp?TicketNum=" & objRS("Ticket_Number") & "'>" & objRS("Ticket_Number")& "</a></td>")


                Response.Write "<td>" & objRS("Escalation_Type") &"</td>"
                Response.Write "<td>" & objRS("First_Name") &"</td>"
                Response.Write "<td>" & objRS("Last_Name") & "</td>"
                Response.Write "<td>" & objRS("Account_Number") & "</td>"
                Response.Write "<td>" & objRS("Phone_Number") & "</td>"
                Response.Write "<td>" & objRS("Cae_Name") & "</td>"
                Response.Write "<td>" & objRS("Cust_Com") & "</tr></td>"
                Response.Write "<td>" & objRS("Status") & "</td>"
                Response.Write "<td>" & objRS("Wip_Com") & "</td>"

objRS.MoveNext

    Loop
        objRS.Close


        %>

    </table>
        </div>


<%
objRS.Open "Escalation_Forms", objConn, 0, 1
' Loop through recordset and display results
If Not objRS.EOF Then



    objRS.MoveFirst
    ' the form below calls this file only this time with an id in the QueryString

    %>


    <option value="<%= objRS.Fields("Escalation_Type") %>"></option>

<p>&nbsp;</p>
    <form action="Eta_database3.asp" method="get" style="text-align: center">
    <select name="Escalation_Type" size="1">
        <option selected>Choose One</option>
        <option>Eta</option>
        <option>HDTV Call Back</option>
        <option> Supervisor Call Back</option>
    </select>&nbsp;&nbsp;&nbsp; <b>&nbsp;Open:</b><input type="checkbox" name="C1" value="ON">&nbsp;&nbsp;&nbsp;
    <b>Pending:</b><input type="checkbox" name="C2" value="ON">&nbsp;&nbsp;&nbsp;
    <b>Close:</b><input type="checkbox" name="C3" value="ON"><p><input type="submit" value="Submit"/>
    <INPUT type="reset" value="Clear"></p>
    </form>
    <%
End If

' Close Data Access Objects and free DB variables
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>

</body>
</htm>


 
Old July 20th, 2004, 02:22 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

In the file Results.asp change this (near the top):
Code:
TicketNum = Request.QueryString("Ticket_Number")
to this:
Code:
TicketNum = Request.QueryString("TicketNum")




Similar Threads
Thread Thread Starter Forum Replies Last Post
Incorrect Syntax Error. binici ASP.NET 2.0 Basics 2 January 12th, 2007 01:33 AM
Line 1: Incorrect syntax near ')'. how to fix it khaink ASP.NET 1.0 and 1.1 Basics 1 September 20th, 2006 06:20 AM
Error: Line 8: Incorrect syntax near '.' ; Help! Fly4High SQL Server 2000 2 August 15th, 2006 03:02 AM
Line 1: Incorrect syntax near '1'. martin1 Visual Basic 2005 Basics 1 June 26th, 2006 01:06 PM
Line 6: Incorrect syntax near garrydawkins SQL Server 2000 2 April 10th, 2006 03:39 PM





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