1
votes

When I want to update row with type 'date' in oracle database through asp.net C# method it gives the following error:

error: ORA-00932: inconsistent datatypes: expected NUMBER got TIMESTAMP

code:

string query = String.Format("update mms_meetings m set m.end_date = :end_date where m.id = :id");

    OracleCommand cmd = new OracleCommand("", GetDBConnection());
    cmd.CommandType = CommandType.Text;
    cmd.CommandText = query;

    OracleParameter opId = new OracleParameter();
    opId.DbType = DbType.Int32;
    opId.Value = meetId;
    opId.ParameterName = "id";

    cmd.Parameters.Add(opId);

    OracleParameter opDateEnd = new OracleParameter();
    opDateEnd.DbType = DbType.DateTime;
    opDateEnd.Value = dateEnd;
    opDateEnd.ParameterName = "end_date";
    cmd.Parameters.Add(opDateEnd);

    cmd.ExecuteNonQuery();
    cmd.Dispose();

    CloseDBConnection(); 
1
Which of type is the end_date in your DB? - Hamlet Hakobyan
Try changing order in which you are adding parameters to the order used in query - end_date first, id - second. - Mikhail
@Mikhail Oracle doesn't use parameter names to distinguish the appropriate one? - Hamlet Hakobyan
@HamletHakobyan Sometimes it is, sometimes is's not, (for example, stackoverflow.com/questions/959242/…), so worth trying to place them in correct order :) - Mikhail
Placing in correct order was the problem. - theChampion

1 Answers

3
votes

1) You must send the exact format for your date as specified in your table column. Check default format for your date column. Like

'yyyy/MM/dd'

2) If you are using OleDb or ODBC Connection, they both use positional parameters so order of adding the parameters is very important. Try changing the order of your parameter to see if it helps.