hai ,
I used LINQ in application. I want to perform batch update.
For that i used the code as:

int[] istudentId = new int[];
 int j = 0;
        for (int i = 0; i < GrdStudent.Rows.Count; i++)
 if ((GrdStudent.Rows[i].FindControl("chkSelect") as CheckBox).Checked)
istudentId[j] = ObjStudent.Student_Id;
DataContext ctx = new DataContext();  
ctx.ExecuteCommand("update SCH_Student_Promotion_Master set Class_Id='" + DdlClassTo.SelectedValue + "' where Student_Id in('" + istudentId + "')", "", "");

but i got some Error like:
Conversion failed when converting the varchar value 'System.Int32[]' to data type int.

Thanks in advance


Member Avatar

Are Class_Id and Student_Id int or string?

If they are ints, remove the single quotes.

Also I suggest using stored procedures as you are vulnerable to SQL injection attacks doing it this way.