Worrior Worrior - 3 months ago 9
ASP.NET (C#) Question

why showing this error, syntex error near ','?

When I am going to insert this value it showing

syntax error
near
','
. I cannot sort out the problem

protected void Button1_Click(object sender, EventArgs e)
{
qry = "insert [Customer_ID],[Factory_Name],[Factory_Address],[Contuct_Persion],[Contuct_Number],[Software_Name_And_Version],[Dongle_Number],[Modeul_Name],[Software_Dalivery_Date],[Remarks] into MastTechSoftwareInformation values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text.ToString() + "','" + TextBox10.Text + "')";

con = new SqlConnection(connection);

cmd = new SqlCommand(qry, con);

con.Open();

cmd.ExecuteNonQuery();

con.Close();

Label1.Text = "Record Inserted.";
}

Answer

try

 qry = "insert into MastTechSoftwareInformation  ([Customer_ID],[Factory_Name],[Factory_Address],[Contuct_Persion],[Contuct_Number],[Software_Name_And_Version],[Dongle_Number],[Modeul_Name],[Software_Dalivery_Date],[Remarks]) values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text.ToString() + "','" + TextBox10.Text + "')";

You have missed () for columns and the columns are should be after "into tablename"

Comments