My Database is not getting Update

    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.....................
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.

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)
'... Do whatever'
'... Then when it comes to committing the changes'
'.... Theres also a GetUpdateCommand() [For amending existing fields]'
'.... And GetInsertCommand() [For creating adding new rows]'

Open in new window

CWareIndiaAuthor Commented:
My code is like that please tell me what is wrong in it.
DataGridView.Rows.RemoveAt(DataGridView.CurrentRow.Index)   OleDbCommandBuilder.GetUpdateCommand();
 My Datagrid update but changes are not reflecting in database.
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.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook 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.
Can you show me the code your using, with the GetDeleteCommand implemented.
nishant joshiTechnology Development ConsultantCommented:
dataset.commitchanges method should be first then update.
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.

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:
CWareIndiaAuthor Commented:
i got my solution.
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.