Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OdbcParameter - Unable to a database update

8 views
Skip to first unread message

- fail database update@discussions.microsoft.com OdbcParameter - fail database update

unread,
Jun 16, 2009, 9:01:01 AM6/16/09
to
I have created an ODBCDataAdapter and then created a UpdateCommand using the
sql statement "update tab_author set auth_id = ? where auth_num = ?"

For the updatecommand I have created 2 new paramaters

adapter.UpdateCommand.Parameters.Add("@auth_id", OdbcType.Char, 3, "auth_id");

and then

OdbcParameter param = new OdbcParameter();
param.DbType = DbType.Int32;
param.Size = 10;
param.ParameterName = "@auth_num";
param.SourceVersion = DataRowVersion.Original;
param.SourceColumn = "auth_num";
adapter.UpdateCommand.Parameters.Add(param);

This paramater refers to a serial key in a database. When I do an update I
get the following error message "Invalid string or buffer length". If I
don't include the serial paramater and instead hard code the serial into the
sql statement, the update works.

I can't do this because I believe that the DBConcurrencyException error will
not be thrown when doing updates if I don't have the serial field as a
paramater..

So how do I created a OdbcParameter that refers to a serial key in a database.

LowLevelAlbert

unread,
Jun 18, 2009, 10:12:01 PM6/18/09
to
For DbType.Int32 you shouldn't touch param.Size. After initializing the
param leave it and that should fix your problem.
0 new messages