ODBC adapter update command syntax nothing happens



this is the call

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

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

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

OdbcDataAdapter adapter = new OdbcDataAdapter(selectCommand, connection);

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

OdbcType.Char, 8, "CommodityKey");

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.

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