Click here to Skip to main content
15,887,346 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[liteusers]' at line 1

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: MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[liteusers]' at line 1

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[liteusers]' at line 1]
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +276
MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) +68
MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId) +17
MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) +110
MySql.Data.MySqlClient.MySqlDataReader.NextResult() +783
MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +1743
MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +4
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +10
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +140
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +316
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +86
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1482
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75
System.Web.UI.Control.EnsureChildControls() +83
System.Web.UI.Control.PreRenderRecursiveInternal() +42
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929



ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" DataSourceID="SqlDataSource1">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                ShowSelectButton="True" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:nnscomm_appConnectionString %>" 
        DeleteCommand="DELETE FROM [liteusers] WHERE [id] = ?" 
        InsertCommand="INSERT INTO [liteusers] ([id], [number], [name], [emailid], [status], [days_left], [commodities], [start_date], [IMEI], [passcode], [verificationcode]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" 
        ProviderName="<%$ ConnectionStrings:nnscomm_appConnectionString.ProviderName %>" 
        SelectCommand="SELECT * FROM [liteusers]" 
        UpdateCommand="UPDATE [liteusers] SET [number] = ?, [name] = ?, [emailid] = ?, [status] = ?, [days_left] = ?, [commodities] = ?, [start_date] = ?, [IMEI] = ?, [passcode] = ?, [verificationcode] = ? WHERE [id] = ?">
        <DeleteParameters>
            <asp:Parameter Name="id" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="id" Type="Int32" />
            <asp:Parameter Name="number" Type="String" />
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="emailid" Type="String" />
            <asp:Parameter Name="status" Type="String" />
            <asp:Parameter Name="days_left" Type="Int32" />
            <asp:Parameter Name="commodities" Type="String" />
            <asp:Parameter Name="start_date" Type="DateTime" />
            <asp:Parameter Name="IMEI" Type="String" />
            <asp:Parameter Name="passcode" Type="String" />
            <asp:Parameter Name="verificationcode" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="number" Type="String" />
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="emailid" Type="String" />
            <asp:Parameter Name="status" Type="String" />
            <asp:Parameter Name="days_left" Type="Int32" />
            <asp:Parameter Name="commodities" Type="String" />
            <asp:Parameter Name="start_date" Type="DateTime" />
            <asp:Parameter Name="IMEI" Type="String" />
            <asp:Parameter Name="passcode" Type="String" />
            <asp:Parameter Name="verificationcode" Type="String" />
            <asp:Parameter Name="id" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>
Posted

1 solution

When using MYSQL the delimiter character for table/column names is not [ ] but ` i.e:
SQL
INSERT INTO `liteusers` ... 
 
Share this answer
 
v2
Comments
[no name] 26-Dec-15 7:21am    
Sorry for asking here: Is
INSERT INTO liteusers ....
wrong in MYSQL? Thank you in advance and 5.
Mehdi Gholam 26-Dec-15 8:49am    
No you can omit the ` character if the names don't have spaces etc.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900