c# - Informix database via odbc connection - Issue with insert stored procedure -
this stored proc. - sp_insertinfo inserts entry table.
i connecting via odbc dsn informix database.
this code, 1 doesn't throw me error or doesn't insert record.
i connected via sequelink 3.10 32-bit driver, application runs on 64-bit os.
trying identify why data not getting inserted(when put breakpoint, parameterized statement actual db, there inserts same data, fails when run application code).
int rowsinserted = command.executenonquery(); //this line returning -1 , data doesn't inserted.
any thoughts/idea helpful?
private void insertinfo() { try { using(var connection = new odbcconnection("dsn=mydsn;uid=myusername;pwd=****;")) { var command = connection.createcommand(); command.commandtype = commandtype.storedprocedure; command.connection = connection; command.commandtext = "execute procedure sp_insertinfo(?,?)"; command.parameters.clear(); //insert parameter values var paramid = new odbcparameter("id", odbctype.int) { value = convert.toint32(txtid.text.trim()) }; command.parameters.add(paramid); var paramcountry = new odbcparameter("country", odbctype.varchar, 25) { value = txtcountry.text.trim() }; command.parameters.add(paramcountry); connection.open(); int rowsinserted = command.executenonquery(); //this line returning -1 , data doesn't inserted. if (rowsinserted > 0) { messagebox.show("insert data saved."); } } } catch (exception ex) { messagebox.show(ex.tostring()) ; } }
at first try execute procedure simple statement, not prepared statement. like:
command.commandtext = "execute procedure sp_insertinfo(1, 'poland')"; connection.open(); int rowsinserted = command.executenonquery();
this way see if problem prepared statement.
try execute execute procedure sp_insertinfo(1, 'poland')
via dbaccess
(informix tool). way see if odbc issue.
if not work dbaccess
have debug sp_insertinfo
. if work, problem odbc. suggest enabling odbc trace in odbc manager
, analyzing log produce.
Comments
Post a Comment