none
SqldataAdaptor.Update method not working RRS feed

  • Question

  • Hi all...

    I ma facing one problem in my application. I am getting data from my database , i fill it in Dataset.
    After that, i am deleting 1 row from 1 table of dataset, and re- populating it on database(sql server 2005(.
    My code goes as follows :

     SqlCommand sqlcomm = new SqlCommand();
                sqlcomm.CommandText ="Select * from User_table";
                sqlcomm.Connection = sqlconn;
                sqldata_adp.SelectCommand = sqlcomm;
                sqldata_adp.Fill(dtSet,"user_table");
                DataTable dttab =(DataTable) dtSet.Tables[0];
                
                dttab.Rows[1].Delete();
                if (dtSet.HasChanges())
                {
                   sqldata_adp.ContinueUpdateOnError = true;
                   SqlCommandBuilder sbuild = new SqlCommandBuilder(sqldata_adp);
                   DataSet dtset_new =  dtSet.GetChanges(DataRowState.Deleted);
                   bool berror = dtset_new.HasErrors;
                   sqldata_adp.AcceptChangesDuringFill = true;
                   dtSet.AcceptChanges();
                   dtSet.Tables[0].AcceptChanges();
                   sqldata_adp.Update(dtSet,"user_table");               
                }


    But , i am not getting effect on database.. i.e. row is not getting deleted actually from database..
    Can you plz, tell me.. how to solve this ??

    Thanks in advance,
    Jicky.
    • Moved by Peter Gvozdjak - MSFT Friday, July 24, 2009 6:40 PM Moving to the DataSet forum. (From:SQL Server Data Access)
    Tuesday, July 21, 2009 8:22 AM

Answers