Line 1: Incorrect syntax near ')'. how to fix it

Discussion in '.NET' started by levis, Sep 20, 2006.

  1. levis

    levis

    Joined:
    Sep 20, 2006
    Messages:
    1
    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 :
    ------------------

    <%@ 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>
    <!--#INCLUDE file="adminHeader.aspx"-->
    <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>
     
    levis, Sep 20, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    10,721
    Patrick.O.Ige
    Oct 11, 2004
  2. Patrick Olurotimi Ige
    Replies:
    4
    Views:
    7,026
    Patrick Olurotimi Ige
    Mar 18, 2005
  3. JMUApache
    Replies:
    2
    Views:
    3,312
    Brendan Reynolds
    Sep 4, 2005
  4. David

    Incorrect syntax near 'int'

    David, Apr 6, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    2,483
    David
    Apr 7, 2006
  5. iporter

    Line 1: Incorrect syntax near '<'.

    iporter, Dec 22, 2006, in forum: Javascript
    Replies:
    1
    Views:
    166
    iporter
    Dec 22, 2006
Loading...

Share This Page