Groups | Blog | Home
all groups > dotnet odbc.net > march 2006 >

dotnet odbc.net : update command no action occurs syntax missing what?


cindy
3/11/2006 7:57:45 AM
this is the call

private void Page_Load(object sender, System.EventArgs e)
{
OdbcConnection connection = new OdbcConnection ("DSN=PFW52");
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.
--
lukezhan NO[at]SPAM online.microsoft.com
3/13/2006 7:04:14 AM
Hello Cindy,

From the code, I didn't see you set the value for parameter "@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";


So the Update command is not compeleted:

UPDATE INCOMMOD SET CommodityShortDescr =X WHERE rtrim(CommodityKey) = ?




Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
AddThis Social Bookmark Button