A
Assimalyst
Hi,
I'm attempting to update an SQL Server database from a datagrid. I have
followed one of microsofts walkthroughs as far as possible, but I am
using stored procedures where it did not, though i don't think that
should be a problem.
Here's the code:
private void DataGrid1_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
TextBox tb;
tb = (TextBox)(e.Item.Cells[5].Controls[0]);
string strHistology = tb.Text;
sqlDataAdapter1.UpdateCommand.Parameters["@sampleNo"].Value = key;
sqlDataAdapter1.UpdateCommand.Parameters["@histology"].Value =
strHistology;
sqlDataAdapter1.Update(dsSample1);
DataGrid1.EditItemIndex = -1;
}
The string values key & strHistology are getting written correctly (87
& Squamous respectively) and the update query works with these values
using query analyser, but for some reason the updates are either not
been written to the dataset and/or the database using the above code.
Any ideas?
Thanks.
I'm attempting to update an SQL Server database from a datagrid. I have
followed one of microsofts walkthroughs as far as possible, but I am
using stored procedures where it did not, though i don't think that
should be a problem.
Here's the code:
private void DataGrid1_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
TextBox tb;
tb = (TextBox)(e.Item.Cells[5].Controls[0]);
string strHistology = tb.Text;
sqlDataAdapter1.UpdateCommand.Parameters["@sampleNo"].Value = key;
sqlDataAdapter1.UpdateCommand.Parameters["@histology"].Value =
strHistology;
sqlDataAdapter1.Update(dsSample1);
DataGrid1.EditItemIndex = -1;
}
The string values key & strHistology are getting written correctly (87
& Squamous respectively) and the update query works with these values
using query analyser, but for some reason the updates are either not
been written to the dataset and/or the database using the above code.
Any ideas?
Thanks.