My Database is not getting Update

Hi,
    I am creating windows application using MS Access database, and dot net 3.5. I am trying to delete rows from database using dataset. My problem is that when i use adapter.update and dataset.commitchanges method ,row from datagrid deleted but my database remains the same, no row is deleting from database. Please help me.....................
CWareIndiaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gman84Commented:
You need to use a Commnd builder. Which needs to be instansiated at the same time as the adaptor is.

Dim oCBuilder as OleDb.OleDbCommandBuilder

'... Create Adaptor'
oCBuilder = New OleDb.OleDbCommandBuilder(oAdaptor)
oAdaptor.Fill(oDataSet)
'... Do whatever'
'... Then when it comes to committing the changes'
oCBuilder.GetDeleteCommand()
'.... Theres also a GetUpdateCommand() [For amending existing fields]'
'.... And GetInsertCommand() [For creating adding new rows]'
oAdaptor.Update(oDataSet)

Open in new window

0
CWareIndiaAuthor Commented:
My code is like that please tell me what is wrong in it.
DataGridView.Rows.RemoveAt(DataGridView.CurrentRow.Index)   OleDbCommandBuilder.GetUpdateCommand();
   OleDbDataAdapter.Update(DataTable);
            DataGridView..Update();
           DataTable.AcceptChanges();
   
 My Datagrid update but changes are not reflecting in database.
0
gman84Commented:
GetDeleteCommand() - will delete specified rows
GetUpdateCommand() - will only alter values that are in existing fields.
GetInsertCommand() - will insert new rows.

You need to use GetDeleteCommand() in this instance.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

CWareIndiaAuthor Commented:
GetDeleteCommand is also not working.
I am also not able to insert new record in database . When i connect to sql server and use same code, changes reflect in database. What could be the problem.
0
gman84Commented:
Can you show me the code your using, with the GetDeleteCommand implemented.
0
nishant joshiTechnology Development ConsultantCommented:
dataset.commitchanges method should be first then update.
0
CWareIndiaAuthor Commented:
Hi , i got my solution.actually each time when i built the project my database copy in to bin folder, and all changes were lost. actually when i update records, it updated from bin folder database and when i built the project bin database replace with actual database and changes were lost. When i set  'copy to output directory'='Copy when newer' of database property.My problem solved.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CWareIndiaAuthor Commented:
closed.
0
CWareIndiaAuthor Commented:
i got my solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.