ODBC adapter update command syntax nothing happens

G

Guest

this is the call

private void Page_Load(object sender, System.EventArgs e)
{
OdbcConnection connection = new OdbcConnection ("DSN=xyz");
CreateDataAdapter(connection);
}

this is the code, no errors, but NO UPDATE I have to use ODBC I just need to
update a field based on a key, EMBARASSED to say days going around syntax
PLEASE SOMEONE

public static OdbcDataAdapter CreateDataAdapter(OdbcConnection connection)
{
string selectCommand ="SELECT rtrim(CommodityKey), CommodityShortDescr
FROM INCOMMOD";

OdbcDataAdapter adapter = new OdbcDataAdapter(selectCommand, connection);

adapter.UpdateCommand = new OdbcCommand( "UPDATE INCOMMOD SET
CommodityShortDescr = ? WHERE rtrim(CommodityKey) = ?");

adapter.UpdateCommand.Parameters.Add("@CommodityKey",
OdbcType.Char, 8, "CommodityKey");

adapter.UpdateCommand.Parameters.Add("@CommodityShortDescr",
OdbcType.Char, 1, "CommodityShortDescr");

adapter.UpdateCommand.Parameters["@CommodityShortDescr"].Value = "X";

return adapter;

}

no errors, no update occurs, the statement runs on server engine using
pervasive SQL and control center the update statement works.
 
S

Sericinus hunter

I don't see at what point you expect the update to be performed. Also,
looks like you don't assign a value to the CommodityKey parameter.

In fact, you do not need the adapter for this simple update. Try just
to create an OdbcCommand object with the update command string and
parameters like you already have, and call OdbcCommand.ExecuteNonQuery
method, at which point the actual update should be made.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top