954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Batch Update

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

ssreevidya.m
Junior Poster in Training
51 posts since Jan 2009
Reputation Points: 10
Solved Threads: 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.

stbuchok
Master Poster
730 posts since May 2011
Reputation Points: 120
Solved Threads: 93
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: