Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 September 20th, 2006, 06:05 AM
Authorized User
 
Join Date: Oct 2005
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Line 1: Incorrect syntax near ')'. how to fix it

hi there,
can anyone tell me why i get this error and how to fix it :

-------------------------------------------

Line 1: Incorrect syntax near ')'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near ')'.

Source Error:

Line 63: MyCommand = New SqlDataAdapter(sqlstr, MyConnection)
Line 64: MyDataset = New DataSet
Line 65: MyCommand.Fill(MyDataset, "Customers")
Line 66: DataGrid1.DataSource = MyDataset.Tables("Customers").DefaultView
Line 67: DataBind()

-------------------------------------------------------------
here is my code :
------------------


Code:
<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="system.io" %>
<script runat="server">

Dim Conn As String = ConfigurationSettings.AppSettings("Conn")
dim MyConnection as SqlConnection=new SqlConnection(Conn)
dim MyDataset As DataSet
dim MyTable As DataTable
Dim myReader As SqlDataReader
dim MyCommand As SqlDataAdapter
Dim catCMD As SqlCommand = MyConnection.CreateCommand()
dim sqlstr As String
dim ACurrency
dim SQLUser
sub Page_Load(obj as object, e as eventargs)
    if session("Admin")="" then response.redirect ("../admin.aspx")
    sqlstr = "select ACurrency from SConstants"
    MyCommand = New SqlDataAdapter(sqlstr, MyConnection)
    MyDataset = New DataSet
    MyCommand.Fill(MyDataset)
    MyTable = MyDataset.Tables(0)
    If MyTable.Rows.Count > 0 then
        ACurrency=MyTable.Rows(0).Item("ACurrency")
    end if
    if not ispostback then
        ToGrid()
    end if
end sub

sub Change(obj as object, e as eventargs)
    dim DeliverStatus
    if obj.CommandName=0 then
        DeliverStatus=1
    else
        DeliverStatus=0
    end if
    sqlstr = "UPDATE Orders SET DeliverStatus = " & DeliverStatus & " Where Order_Number = '" & obj.CommandArgument & "'"
    MyCommand = New SqlDataAdapter(sqlstr, MyConnection)
    MyDataset = New DataSet
    MyCommand.Fill(MyDataset)
    ToGrid()
End Sub

function ToGrid()
    if request("Userid")<>"" then
        SQLUser=" where Orders.Userid=" & request("Userid")
    end if
    sqlstr="SELECT Order_Number,Orders.UserTempID,Customers.UserID,FirstName,LastName,Orders.PayMethodID,PayMethodName,DeliverStatus,Total,ODate,CardStatus FROM Customers Inner JOIN (PayMethod Inner JOIN (Orders left join CreditCards on Orders.UserTempID=CreditCards.UserTempID) ON PayMethod.PayMethodID = Orders.PayMethodID) ON (Customers.UserID = Orders.UserID)" & SQLUser & " order by Odate Desc"
    MyCommand = New SqlDataAdapter(sqlstr, MyConnection)
    MyDataset = New DataSet
    MyCommand.Fill(MyDataset, "Customers")
    DataGrid1.DataSource = MyDataset.Tables("Customers").DefaultView
    DataBind()
end function

Sub SortResults(sender as Object, e as DataGridSortCommandEventArgs)
    if request("Userid")<>"" then
        SQLUser=" where Cart.Userid=" & request("Userid")
    end if
   sqlstr="SELECT Order_Number,Orders.UserTempID,Customers.UserID,FirstName,LastName,Orders.PayMethodID,PayMethodName,DeliverStatus,Total,ODate,CardStatus FROM Customers Inner JOIN (PayMethod Inner JOIN (Orders left join (CreditCards) on Orders.UserTempID=CreditCards.UserTempID) ON PayMethod.PayMethodID = Orders.PayMethodID) ON (Customers.UserID = Orders.UserID)" & SQLUser & " order by " & e.SortExpression & ""
    MyCommand = New SqlDataAdapter(sqlstr, MyConnection)
    MyDataset = New DataSet
    MyCommand.Fill(MyDataset, "Customers")
    DataGrid1.DataSource = MyDataset.Tables("Customers").DefaultView
    DataBind()
End Sub
</script>
<html>
<head>
    <title>Shopping Cart Administration</title>
</head>
<body>
<center>

<table cellpadding=0 cellspacing=0 border=0 width=749 class=fontm>
<tr>
    <td>
<strong>Orders Report</strong><br><br>
<%if request("update")="1" then%>
    Payment status was updated successfully<br><br>
<%end if%>
<form runat="server">
<asp:DataGrid id="DataGrid1" runat="server" BorderColor="#456298" GridLines="Both" cellpadding="4" cellspacing="0" Font-Names="Arial" Font-Size="13px" HeaderStyle-BackColor="#456298" ItemStyle-BackColor="#ffffff"  AutoGenerateColumns="false" AllowSorting="true" OnSortCommand="SortResults">
<HeaderStyle forecolor="White" font-bold="True" horizontalalign="Center"></HeaderStyle>
<Columns>
    <asp:TemplateColumn HeaderText="Order ID" SortExpression="Order_Number">
    <ItemTemplate>
        <A href="OrderDetails.aspx?id=<%# Container.DataItem("UserTempID")%>"><%# Container.DataItem("Order_Number")%></A>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Name" SortExpression="LastName">
    <ItemTemplate>
        <A href="CustomerDetails.aspx?id=<%# Container.DataItem("UserID")%>"><%# Container.DataItem("FirstName") & " " & Container.DataItem("LastName")%></A>
    </ItemTemplate>
    </asp:TemplateColumn>

    <asp:TemplateColumn HeaderText="Paid by" SortExpression="PayMethodName">
    <ItemTemplate>
        <%# IIF(Container.DataItem("PayMethodID")=1,"<a href=CardDetails.aspx?id=" & Container.DataItem("UserTempID") & ">","")%><%# Container.DataItem("PayMethodName")%><%# IIF(Container.DataItem("PayMethodID")=1,"</a>","")%>
    </ItemTemplate>
    </asp:TemplateColumn>

    <asp:TemplateColumn HeaderText="CC Status" SortExpression="DeliverStatus">
    <ItemTemplate>
        <%# IIF(IsDBNull(Container.DataItem("CardStatus")),"<center>-</center>",Container.DataItem("CardStatus")) %>
    </ItemTemplate>
    </asp:TemplateColumn>

    <asp:TemplateColumn HeaderText="Shipment" SortExpression="DeliverStatus">
    <ItemTemplate>
        <%# IIF(Container.DataItem("DeliverStatus")=0,"Pending","Shipped")%>
    </ItemTemplate>
    </asp:TemplateColumn>

    <asp:TemplateColumn HeaderText="Change Status">
    <ItemTemplate>
        <asp:button id="btChange" onclick="Change" CommandName='<%# Container.DataItem("DeliverStatus") %>' CommandArgument='<%# Container.DataItem("Order_Number") %>' Text='<%# IIF(Container.DataItem("DeliverStatus")=0,"Mark as Shipped","Change to Pending")%>' width=130 runat="server" />

    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Total Price" SortExpression="Total">
    <ItemTemplate>
        <%# ACurrency & Container.DataItem("Total") %>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumn HeaderText="Date" DataField="ODate" SortExpression="ODate" />
</Columns>
</asp:DataGrid>
</form>
</td>
</tr>
</table>    
</center>
</body>
</html>
 
Old September 20th, 2006, 06:20 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I think its is your SQL command which is throwing the error.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.




Similar Threads
Thread Thread Starter Forum Replies Last Post
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
Error Line 1: Incorrect syntax near '='. Calibus Classic ASP Databases 9 July 20th, 2004 02:22 PM
Incorrect syntax...... Adam H-W Classic ASP Databases 8 June 21st, 2004 11:14 AM





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