Solved

Changing value of bound datagridview cell

Posted on 2013-06-04
3
417 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
ID: 39220758
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
ID: 39232581
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
ID: 39243888
I solved it without using experts advice. Thank you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unable to upgrade to .Net 4.6.2 on Server 2012r2 2 42
SQL syntax in VB.net 5 29
C# HTTP GET method sample code 3 40
C# Single Form 8 27
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

21 Experts available now in Live!

Get 1:1 Help Now