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]
- (e-mail address removed)
Brian Conway said:
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();
message news:
[email protected]...
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]
- (e-mail address removed)
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.