How can I pass multiple named parameters using ODBC to a DB2 database -
i have query db2 database using existing odbc connection. executing simple queries works expected, try execute parameterised query doesn't work:
select columna, columnb mytable columna = ? , columnb = ?
using ?
suggested in other posts, empty results (no error messages though). when try standard sql way named parameters (and changing sql statement columna = @columna , columnb = @columnb
shown below
odbccommand.parameters.addwithvalue( columna", 1234 ); odbccommand.parameters.addwithvalue( columnb", 9999);
the following error message shown:
system.data.odbc.odbcexception: error [42s22] [ibm][cli driver][db2] sql0206n "@columna" not valid in context used. sqlstate=42703...
using odbccommand.parameters.add( new odbcparameter( "columna", integer ){ value = 1234 } );
instead shows deprecated (and doesn't work). i'd avoid using concatenated sql statements, can't find way parameterised queries working against db2 database.
you failed mention db2 version. in db2 9.7 , later there driver parameter db2netnamedparam
controls behaviour. check db2cli.ini
file.
i suspect named parameters may not supported in earlier versions.
Comments
Post a Comment