[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

update command no action occurs syntax missing what?

cindy

3/11/2006 3:58:00 PM

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.
--
cindy
1 Answer

lukezhan

3/13/2006 7:04:00 AM

0

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.)