Re: Looping through a Datagrid
From: Brian Conway (Brian.Conway_at_qwest.com)
Date: 06/14/04
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Using the FtpCommand function in wininet.dll"
- Previous message: Krish: "DataTable questions"
- In reply to: Nicholas Paldino [.NET/C# MVP]: "Re: Looping through a Datagrid"
- Next in thread: Nicholas Paldino [.NET/C# MVP]: "Re: Looping through a Datagrid"
- Reply: Nicholas Paldino [.NET/C# MVP]: "Re: Looping through a Datagrid"
- Messages sorted by: [ date ] [ thread ]
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.
> > > >
> > > >
> > >
> > >
> >
> >
>
>
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Using the FtpCommand function in wininet.dll"
- Previous message: Krish: "DataTable questions"
- In reply to: Nicholas Paldino [.NET/C# MVP]: "Re: Looping through a Datagrid"
- Next in thread: Nicholas Paldino [.NET/C# MVP]: "Re: Looping through a Datagrid"
- Reply: Nicholas Paldino [.NET/C# MVP]: "Re: Looping through a Datagrid"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|