SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : Microsoft .NET :

Previous DiscussionNext Discussion
 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 NamePoints ScoredPoints Allowed
Team A103
Team B2017
Team C1410


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.

No Responses

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.