PDA

View Full Version : آپدیت همزمان چند رکورد از گریدویو



adineh67
پنج شنبه 04 تیر 1394, 09:00 صبح
سلام
واسه آپدیت چند تا رکورد بصورت همزمان از کد زیر استفاده کردم اما به قسمت where دستورم گیر میده ممنون میشم راهنمایی بفرمایید،خیلی فوری هست :افسرده:



StringBuilder strSql = new StringBuilder(string.Empty);
SqlCommand cmd = new SqlCommand();
for (int i = 0; i < grdSelectedStudent.Rows.Count; i++)
{
TextBox chkUpdate = (TextBox)
grdSelectedStudent.Rows[i].Cells[0].FindControl("TextBox1");
if (chkUpdate != null)
{

string strscore = chkUpdate.Text.Trim();

string strUpdate =
"Update dbo.TBLGrade set dbo.TBLGrade.Score = " + strscore
+ " Where dbo.TBLGrade.CoursegroupID =" + Connection.s ;
strSql.Append(strUpdate);

}
}
try
{
cmd.CommandType = CommandType.Text;
cmd.CommandText = strSql.ToString();
cmd.Connection = Cn;
Cn.Open();
cmd.ExecuteNonQuery();
}
catch (SqlException ex)
{
string errorMsg = "Error in Updation";
errorMsg += ex.Message;
throw new Exception(errorMsg);
}
finally
{
Cn.Close();
}

crazy_1892
پنج شنبه 04 تیر 1394, 17:38 عصر
لطفا خطای مربوطه را قرار دهید