[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.odbcnet

OdbcParameter - Unable to a database update

OdbcParameter - fail database update

6/16/2009 1:01:00 PM

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.

1 Answer

LowLevelAlbert

6/19/2009 2:12:00 AM

0

For DbType.Int32 you shouldn''t touch param.Size. After initializing the
param leave it and that should fix your problem.

"OdbcParameter - fail database update" wrote:

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