Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Runtime exception- Incorrect syntax near '\'.

$
0
0

Hi,

I get a runtime exception -

System.Exception: Insert/Update Error:Incorrect syntax near '\'.

The error comes up on the attached code.

Thanks.

private void AddSysDetail()
        {
            // get the office name to insert
            string SYSTEM_NAME = "", SYSTEM_VENDOR = "", PURCHASE_DT = "", IMPLEMENTATION_DT = "", DATABASE_TYPE = "" , APPLICATION_LANGUAGE = "", REMARKS = "";

            TextBox Inserttxtsys_name = DvSysDetails.FindControl("Inserttxtsys_name") as TextBox;
            if (Inserttxtsys_name != null)
            {
                SYSTEM_NAME = Inserttxtsys_name.Text;
            }
            DropDownList Inserttxtsys_vendor = DvSysDetails.FindControl("Inserttxtsys_vendor") as DropDownList;
            if (Inserttxtsys_vendor != null)
            {
                if (Inserttxtsys_vendor.SelectedItem != null)
                {
                    SYSTEM_VENDOR = Inserttxtsys_vendor.SelectedItem.Text;
                }
            }

            TextBox Inserttxtpur_date = DvSysDetails.FindControl("Inserttxtpur_date") as TextBox;
            if (Inserttxtpur_date != null)
            {
                PURCHASE_DT = Inserttxtpur_date.Text;
            }

            TextBox Inserttxtimp_date = DvSysDetails.FindControl("Inserttxtimp_date") as TextBox;
            if (Inserttxtimp_date != null)
            {
                IMPLEMENTATION_DT = Inserttxtimp_date.Text;
            }
            TextBox Inserttxtdb_type = DvSysDetails.FindControl("Inserttxtdb_type") as TextBox;
            if (Inserttxtdb_type != null)
            {
                DATABASE_TYPE = Inserttxtdb_type.Text;
            }
            TextBox Inserttxtapp_lan = DvSysDetails.FindControl("Inserttxtapp_lan") as TextBox;
            if (Inserttxtapp_lan != null)
            {
                APPLICATION_LANGUAGE = Inserttxtapp_lan.Text;
            }
            TextBox InserttxtREMARKS = DvSysDetails.FindControl("InserttxtREMARKS") as TextBox;
            if (InserttxtREMARKS != null)
            {
                REMARKS = InserttxtREMARKS.Text;
            }
            if (ddlsyst.SelectedItem != null)
            {
                string sqlinsert = string.Format("INSERT INTO [SYSTEM]([SYSTEM_NAME],[SYSTEM_VENDOR],[PURCHASE_DT],[IMPLEMENTATION_DT],[DATABASE_TYPE],[APPLICATION_LANGUAGE],[REMARKS],[LAST_UPDATE_DT],[LAST_UPDATE_USER],[CREATE_DT],[CREATE_USER]) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',{8},'{9}',{10})", SYSTEM_NAME, SYSTEM_VENDOR, PURCHASE_DT, IMPLEMENTATION_DT, DATABASE_TYPE, APPLICATION_LANGUAGE, REMARKS, "getdate()", User.Identity.Name, "getdate()", User.Identity.Name);
                SqlConnection connection = new SqlConnection(GetConnectionString());
                try
                {
                    connection.Open();
                    SqlCommand cmd = new SqlCommand(sqlinsert, connection);
                    cmd.ExecuteNonQuery();
                }

                catch (System.Data.SqlClient.SqlException ex)
                {
                    string msg = "Insert/Update Error:";
                    msg += ex.Message;
                    throw new Exception(msg);
                }

                finally
                {
                    connection.Close();
                }
            }

        }


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>