Solved

Changing value of bound datagridview cell

Posted on 2013-06-04
3
416 Views
Last Modified: 2013-06-13
Hello experts, I am trying to set a value in datagridview via code. the grid is bound to a bounding source.
apparently the data base wont update. this is my code:


Dim row As DataRow = DirectCast(Me.TblLaboratoryBindingSource1.Current, DataRowView).Row
                row("Nomicrosection") = lngNewSeedNoMicroSection
                row("TestDate") = DateTime.Now
                dtgLab.Item("Nomicrosection", i).Value = lngNewSeedNoMicroSection
                dtgLab.Item("TestDate", i).Value = DateTime.Now
dtDataTable.GetChanges()

       
            TblLaboratoryTableAdapter.Update(dtDataTable.Select(Nothing, Nothing, DataViewRowState.Deleted))
           
            TblLaboratoryTableAdapter.Update(dtDataTable.Select(Nothing, Nothing, DataViewRowState.ModifiedCurrent))
         
            TblLaboratoryTableAdapter.Update(dtDataTable.Select(Nothing, Nothing, DataViewRowState.Added))

            COCDataSet.tblLaboratory.AcceptChanges()
0
Comment
Question by:Hagita
  • 2
3 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
What is the underlying query?

Does it use multiple tables?
If so it may be that it is not updateable

mlmcc
0
 

Accepted Solution

by:
Hagita earned 0 total points
Comment Utility
Thank you. I managed to make it work. added a call to the  EndEdit method opf the BindingSource:

           dtDataTable.GetChanges()
            Me.TblLaboratoryBindingSource1.EndEdit()
         
            TblLaboratoryTableAdapter.Update(dtDataTable.Select(Nothing, Nothing, DataViewRowState.Deleted))      
            TblLaboratoryTableAdapter.Update(dtDataTable.Select(Nothing, Nothing, DataViewRowState.ModifiedCurrent))          
            TblLaboratoryTableAdapter.Update(dtDataTable.Select(Nothing, Nothing, DataViewRowState.Added))

            COCDataSet.tblLaboratory.AcceptChanges()
0
 

Author Closing Comment

by:Hagita
Comment Utility
I solved it without using experts advice. Thank you
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now