Mike LaRocca
4/29/2002 9:50:00 PM
Hi everyone,
Would someone be able to take a look at my code sample
below and tell me what's off? I'm finding that I'm able
to fill a dataset from an ODBC source with no trouble,
and basic connectivity seems to be great. But, updates
aren't working, and I'm not getting any sort of error or
status message to troubleshoot.
After running this sample, my C# code completes yet ODBC
logging shows that the ODBC driver was never actually
accessed (except as part of the original data fill).
Here's the sample:
-----------------------
// "dAdapter" is an OdbcDataAdapter
// "dSet" is an OdbcDataSet
// "dConnection" is an OdbcConnection
dAdapter.UpdateCommand = new OdbcCommand("Update
Sample.Person Set Name = ?, DOB = ?, SSN = ?, Home_City
= ?, Home_State = ? Where ID = ?", dConnection);
dAdapter.UpdateCommand.Parameters.Add("Name",
OdbcType.Char);
dAdapter.UpdateCommand.Parameters.Add("DOB",
OdbcType.Date);
dAdapter.UpdateCommand.Parameters.Add("SSN",
OdbcType.Char);
dAdapter.UpdateCommand.Parameters.Add("Home_City",
OdbcType.Char);
dAdapter.UpdateCommand.Parameters.Add("Home_State",
OdbcType.Char);
dAdapter.UpdateCommand.Parameters.Add("ID", OdbcType.Int);
dAdapter.UpdateCommand.Parameters[0].Value = txtName.Text;
dAdapter.UpdateCommand.Parameters[1].Value = txtDOB.Text;
dAdapter.UpdateCommand.Parameters[2].Value = txtSSN.Text;
dAdapter.UpdateCommand.Parameters[3].Value = txtCity.Text;
dAdapter.UpdateCommand.Parameters[4].Value =
txtState.Text;
dAdapter.UpdateCommand.Parameters[5].Value =
lblIDValue.Text;
dAdapter.Update(dSet, "Sample_Person");
-----------------------
Thank you for your help,
-Mike