پیام حیاتی
پنج شنبه 14 اسفند 1393, 16:56 عصر
سلام
این کدهای من هست جهت ویرایش اطلاعات (با دابل کلیک بر روی سلول نام در datagrid نام رو تغییر میدم) :
SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=Project; Integrated Security=TRUE ");
for (int i = 0; i < dataGridView3.RowCount; i++)
{
con.Open();
SqlCommand sc = new SqlCommand();
sc.Connection = con;
sc.CommandText = "update Personels set p_name='" + dataGridView3.Rows[i].Cells[1] + "' where p_id=" + dataGridView3.Rows[i].Cells[0];
sc.ExecuteNonQuery();
}
con.Close();
فرم :
129136
با تغییر نام و کلیک بر روی دکمه update این خطا رو میگیره :
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: Incorrect syntax near '{'.
129137
این کدهای من هست جهت ویرایش اطلاعات (با دابل کلیک بر روی سلول نام در datagrid نام رو تغییر میدم) :
SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=Project; Integrated Security=TRUE ");
for (int i = 0; i < dataGridView3.RowCount; i++)
{
con.Open();
SqlCommand sc = new SqlCommand();
sc.Connection = con;
sc.CommandText = "update Personels set p_name='" + dataGridView3.Rows[i].Cells[1] + "' where p_id=" + dataGridView3.Rows[i].Cells[0];
sc.ExecuteNonQuery();
}
con.Close();
فرم :
129136
با تغییر نام و کلیک بر روی دکمه update این خطا رو میگیره :
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: Incorrect syntax near '{'.
129137