Code elaboration -- which direction to take? Ok, I went back and found an old post on here about doing a sort of "batch" update to a database. ChrisRickard was kind enough to get me started.
Anyway, I put the project on hold for a bit, but I'm ready to resume it.
In my app, I'll have a GridView with four fields: ID, TeamName, PointsScored, and PointsAllowed, and the final two columns will be editable. So it would look something like this:
| Team Name | Points Scored | Points Allowed | | Team A | 10 | 3 | | Team B | 20 | 17 | | Team C | 14 | 10 |
Well, the PointsFor and PointsAgainst column will be text boxes that I want to update all at once. Ergo, a batch insert.
Well, The query itself would look something like this:
odbCommand = new OleDbCommand("INSERT INTO MY_TABLE(TEAM,PF,PA) VALUES(?,?,?)", odbConn);
odbAdapter.InsertCommand = odbCommand;
And, it appears that I need to create a parameter list, like this:
odbCommand.Parameters.Add("TEAM", OleDbType.VarChar, 50, "TEAM"); odbCommand.Parameters.Add("PF", OleDbType.VarChar, 50, "PF"); odbCommand.Parameters.Add("PA",OleDbType.VarChar, 50, "PA");
I get this part of it, and I understand what's going on, but my question is:
How do I get the data from each row in the GridView, and do the batch insert?
Do I just iterate through each row in the grid view, and do the inserts essentially one at a time, or what?
I'm at a bit of a loss here. I'll go back and check the practice code I tried...Started By Monte on Aug 7, 2009 at 8:41:20 AM This message has been edited. |