Srinivas Rao

Srinivas Rao

  • NA
  • 76
  • 17k

'System.Data.SqlClient.SqlException'

Oct 14 2015 4:49 AM

iam getting an error as"An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code

Additional information: Incorrect syntax near the keyword 'user'.

how to rectify the error.....! 
 
 
using System.Data.SqlClient;

namespace emp

{

public partial class details : System.Web.UI.Page

{

SqlConnection con = new SqlConnection("Data Source=SRINU-PC\\sqlexpress;Initial Catalog=register;Integrated Security=True");

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Button1_Click(object sender, EventArgs e)

{

con.Open();

SqlCommand cmd = new SqlCommand("insert into user values ('" + TextBox1.Text + "''" + TextBox2.Text + "''" + TextBox3.Text + "''" + TextBox4.Text + "''" + TextBox5.Text + "')", con);

cmd.ExecuteNonQuery();

con.Close();

Label1.Text = "Values are Inserted";

}

}

}


Answers (3)