none
OracleDataAdapter.Update() not working. RRS feed

  • Question

  •  

    hi.

    i'm workin on asp.net2.0, with oracle 9i backend.

     

    On my webpage’s load, I fetch a few data from db [using a sp say, SP1]. Bind it to grid. User changes this data and clicks on a UPDATE button.

    I create a new datatable out of the data available in the grid control [including the modified values]. This datatable is passed to the update function in the DAL layer.

    In DAL, I’m creating a dataadapter. I’m calling SP1 again and calling adapter.fill(). Thus I have the db records in a dataset called dataDS.

    Using a FOR loop, I’m replaceing the old values in dataDS to the modified values, available in the passed datatable.

    Finally I call the dataset.acceptchanges() method and the adapter.update method. Though the execution is running fine, the data is never updated in the backend! What cud be the problem???

     

    Following is the DAL function.

     

    public static void UpdateData(DataTable dtUpdateData)

            {

                    //Fetch all records from IBT_AFFILIATE and fill OracleDataAdapter.

                    string spName = "SP_FETCH_IBT_AFFILIATE";

                    DataSet dataDS = new DataSet();

     

                    OracleDataAdapter dataAdapter = new OracleDataAdapter();

                    OracleConnection oraConn = new OracleConnection(ConfigHelper.getConnectionString(WDCLib.DAL.Utility.GetConnectionKey()) );

                    OracleCommand oraCmd = new OracleCommand(spName, oraConn);

                    oraCmd.CommandType = CommandType.StoredProcedure;

                    dataAdapter.SelectCommand = oraCmd;

                    OracleParameter op = new OracleParameter("outputRS", OracleType.Cursor);

                    op.Direction = ParameterDirection.Output;

                    oraCmd.Parameters.Add(op);

     

                    dataAdapter.Fill(dataDS); // loads the data from DB to the dataset

     

                    for (int iCount = 0; iCount < dtUpdateData.Rows.Count; iCount++)

                    {

                        //dataDS.Tables[0].Rows[iCount]["Key"] = dtUpdateData.Rows[iCount][0];

                        dataDS.Tables[0].Rows[0]["PIA Modifier Actual"] = dtUpdateData.Rows[iCount][1];

                        dataDS.Tables[0].Rows[iCount]["PIA Modifier Forecast"] = dtUpdateData.Rows[iCount][2];

                        dataDS.Tables[0].Rows[iCount]["Affiliate IBT"] = dtUpdateData.Rows[iCount][3];

                        dataDS.Tables[0].Rows[iCount]["Currency Impact"] = dtUpdateData.Rows[iCount][4];

                    }

                    dataDS.Tables[0].AcceptChanges();

     

                    OracleCommandBuilder cmdbuild = new OracleCommandBuilder(dataAdapter);

                    dataAdapter.Update(dataDS.Tables[0]); // update to db

                }

     

    Am i missing something???

     

    ThanX.

    Wednesday, June 27, 2007 10:03 AM