0

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;
                 j++;
             }
        }
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

Sreevidya

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by stbuchok
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.