Re: Looping through a Datagrid

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Brian Conway (Brian.Conway_at_qwest.com)
Date: 06/14/04


Date: Mon, 14 Jun 2004 13:11:40 -0600

Will this enable me to do a mass update in one shot? Or would it be a per
line basis?

"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in
message news:eyi8CEjUEHA.3908@TK2MSFTNGP10.phx.gbl...
> Brian,
>
> What you can do is instead of attaching to the reader, you can attach
> the command to an OleDbDataAdapter, and then set the UpdateCommand
property
> to an OleDbCommand representing your stored procedure. Then, you would
fill
> a dataset and bind the grid to the dataset. This has its disadvantages
(it
> wont be as fast, and could be an issue, for example). On return, you can
> see the changes in the dataset (or should be able to, through viewstate,
or
> some other mechanism). Then, just pass the dataset back to the adapter,
and
> call Update.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@spam.guard.caspershouse.com
>
>
> "Brian Conway" <Brian.Conway@qwest.com> wrote in message
> news:ONLfX9iUEHA.2716@tk2msftngp13.phx.gbl...
> > Currently I do not have it attached to a dataset. How can I modify it to
> do
> > that? I have seen a couple references to the same thing that you
mentioned
> > about it being connected to a dataset. Here is what I have so far on the
> > datagrid.
> >
> > OleDbConnection conn = new
> >
>
OleDbConnection(ConfigurationSettings.AppSettings["FleetConnectionString"]);
> >
> > conn.Open();
> >
> > OleDbCommand cmd = new OleDbCommand(sqlQuery, conn);
> >
> > cmd.Parameters.Add("@rcInfo", OleDbType.VarChar, 20).Value =
> lblRCInfo.Text;
> >
> > OleDbDataReader dreader = cmd.ExecuteReader();
> >
> > DataGrid1.DataSource = dreader;
> >
> > DataGrid1.SelectedIndex = 0;
> >
> > DataGrid1.DataBind();
> >
> > dreader.Close();
> >
> > conn.Close();
> >
> >
> >
> >
> >
> > "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote
> in
> > message news:O43GqpiUEHA.4064@TK2MSFTNGP11.phx.gbl...
> > > Brian,
> > >
> > > If the data grid is connected to a DataSet as a source, then you
> > should
> > > be able to pass that data set to a DataAdapter, which will cycle
through
> > the
> > > changed rows and update the underlying database. You will need to set
> the
> > > appropriate properties (SelectCommand, InsertCommand, DeleteCommand
and
> > > UpdateCommand) to command objects which will call your stored
procedure
> > > instead of just issuing an insert, delete, or update.
> > >
> > > Hope this helps.
> > >
> > >
> > > --
> > > - Nicholas Paldino [.NET/C# MVP]
> > > - mvp@spam.guard.caspershouse.com
> > >
> > > "Brian Conway" <Brian.Conway@qwest.com> wrote in message
> > > news:%239DsliiUEHA.3016@tk2msftngp13.phx.gbl...
> > > > I desperately need some help in coding how to have a completely
> ediable
> > > > datagrid be able to loop through each row and insert into a database
> > > table.
> > > > I am using a stored procedure in the database to do the insert, so I
> > think
> > > I
> > > > just need to figure out how to get it to loop through all the rows
on
> > the
> > > > grid, and update from there.
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: Looping through a Datagrid
    ... Nicholas Paldino [.NET/C# MVP] ... What you can do is instead of attaching to the reader, ... >> to an OleDbCommand representing your stored procedure. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Convert string to Number
    ... structure.Let me explain you this stored procedure. ... you can change this table structure on the basis of output that you require ... and the primary key/unique key column in the table. ... finally each row's fomula column and the calculation of the formula value ...
    (microsoft.public.sqlserver.mseq)
  • Re: ADO faster than ADO.net ?
    ... Would you mind sending me back your changes so I can see what you did. ... Brian ... "Cor Ligthert" wrote: ... > I also added a procedure with a stored procedure and could win 20%. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: stored proc RETURN_VALUE.... there it is, I want to use it !!!
    ... Thanx Brian... ... message something to do with an exception on ole32.dll... ... deleting and rewriting the stored procedure, ... This is the first time that I've used 'refresh'... ...
    (borland.public.delphi.database.ado)
  • Re: Instructions for Installing a CF Base
    ... does anyone have advice to attaching a non fusion ... cover such as the koxx ones to a CF base? ... Brian O.'s Profile: http://www.unicyclist.com/profile/10744 ...
    (rec.sport.unicycling)