
Untitled
By: a guest on
May 9th, 2012 | syntax:
None | size: 1.00 KB | hits: 16 | expires: Never
In c#.net.im getting invalid column name error but i have given a correct column name,how can i rectify this error [closed]
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=INBLR-RK\SQLEXPRESS;Initial Catalog=dbo.EMployee;Integrated Security=True");
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("INSERT INTO empnew Values (" + textBox1.Text + ", '" + textBox2.Text + "', '" + textBox3.Text + "','" + textBox4.Text + "'," + textBox5.Text + ",'" + textBox6.Text + "','" + textBox7.Text + "','" + dateTimePicker1.Text + "','" + textBox8.Text + "'," + textBox9.Text + ")", conn);
DataSet ds = new DataSet("empnew");
da.Fill(ds);
conn.Close();
}
using(SqlConnection connection = new SqlConnection("ConnString"))
{
connection.Open();
SqlCommand comm = new SqlCommand("insert into table_name(col_name) values (@value)",connection);
comm.Parameters.AddWithValue("@value",theValue);
comm.ExecuteNonQuery();
}