Update command not working !!!

Last post 05-16-2008 5:04 PM by greg.darling. 2 replies.

Sort Posts:

  • Update command not working !!!

    05-12-2008, 1:18 AM
    • Loading...
    • beast
    • Joined on 04-27-2008, 7:15 AM
    • Posts 53

     

     

     

    Hello everyone,

    I'm using the following code to update date [ oracle database ] its not raising any error, but its also not updating [ executeNonQuery returns 0 ]

     

    public int updateMemoData(String memoID, String receiverID, String receiverName, String receiverDept, String startDate, String endDate, String issuerID, String issuerName, String issuerDept, String extDept, Boolean close)

    {

    int effected = 0;

    comm.Parameters.Clear();

    ds.Tables[0].Clear();

    SQL =
    @"update memo_tasks

    set STATUS = :STATUS,

    RECEIVER_ID = :RECEIVER_ID,

    RECEIVER_NAME = :RECEIVER_NAME,

    RECEIVER_DEPT = :RECEIVER_DEPT,

    START_DATE = :START_DATE,

    END_DATE = :END_DATE,

    ISSUER_ID = :ISSUER_ID,

    ISSUER_NAME = :ISSUER_NAME,

    ISSUER_DEPT = :ISSUER_DEPT,

    EXTERNAL_DEPT = :EXTERNAL_DEPT

    WHERE MEMO_ID = :MEMO_ID"
    ;if (close)

    {

    status = statusClose;

    receiverID = receiverName = receiverDept =
    " ";

    }

    else

    {

    endDate =
    " ";

    }

    comm.Parameters.Add(
    "MEMO_ID", memoID);

    comm.Parameters.Add("STATUS", status);

    comm.Parameters.Add("RECEIVER_ID", receiverID);

    comm.Parameters.Add("RECEIVER_NAME", receiverName);

    comm.Parameters.Add("RECEIVER_DEPT", receiverDept);

    comm.Parameters.Add("START_DATE", startDate);

    comm.Parameters.Add("END_DATE", endDate);

    comm.Parameters.Add("ISSUER_ID", issuerID);

    comm.Parameters.Add("ISSUER_NAME", issuerName);

    comm.Parameters.Add("ISSUER_DEPT", issuerDept);

    comm.Parameters.Add("EXTERNAL_DEPT", extDept);

     

    comm.Connection = oaConn;

    comm.CommandText = SQL;

    oaConn.Open();

    effected = comm.ExecuteNonQuery();

    oaConn.Close();

    return effected;

    }

     

     

    any Ideas ?

    thanks in advance.

  • Re: Update command not working !!!

    05-12-2008, 9:49 AM
    Answer
    • Loading...
    • SGWellens
    • Joined on 01-02-2007, 4:27 PM
    • MN, USA
    • Posts 2,581
    • Moderator
      TrustedFriends-MVPs

    When that happens it's usually because the database can't find any records to update.

    Does MemoID have trailing spaces?

    It may look like it should match but it will not.

    Steve Wellens
  • Re: Update command not working !!!

    05-16-2008, 5:04 PM
    Answer

    Are you using System.Data.OracleClient or Oracle.DataAccess.Client?  If Oracle's ODP, you'll need to make sure you add the parameters in the same order they appear in the sql statement.

     If you execute the same update in sqlplus, using bind variables, does it update records?  If you're not sure how to do that, see this post http://forums.asp.net/p/1249036/2304561.aspx#2304561

    Hope it helps,

    Greg

Page 1 of 1 (3 items)