Update statement working in SQL Developer but not in C# -


i have small update query works in sql developer.

update people set months = 8 number = 599 

fairly straight forward. , works - works in c#. problem moment want use parameters (which works on number not on months) stop working.

i have code in c#:

 using (oracleconnection con = new oracleconnection(connectionstring))         {             con.open();             oraclecommand command = con.createcommand();             command.commandtype = commandtype.text;             command.commandtext = "update people " +                               "set months = :months " +                               "where number = :number";             command.parameters.add(":number", oracledbtype.int32).value = number;             command.parameters.add(":months", oracledbtype.int32).value = months;              command.executenonquery();         } 

they both of type number in oracle, , i've tried changing oracledbtype decimal, , pretty without success. odd thing is, :number parameters works, months doesn't updated (it won't crash, doesn't update). if change :months parameter, static value 7 - work.

you should add parameters without leading ':' (look here), try this:

using (oracleconnection con = new oracleconnection(connectionstring)) {     con.open();     oraclecommand command = con.createcommand();     command.commandtype = commandtype.text;     command.commandtext = "update people" +                       "set months = :months " +                       "where number = :number";     command.parameters.add("number", oracledbtype.int32).value = number;     command.parameters.add("months", oracledbtype.int32).value = months;      command.executenonquery(); } 

also missing space after :months in query.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -