It's mostly in the title... I'm using VB (obviously, see below), but I'm a total beginner with visual studio.
Here is the test code I'm using (it is a simple test button I designed to test the problem I have in the code elsewhere):
Private Sub Test_Click(sender As Object, e As EventArgs) Handles Test.Click
Dim FDBdataset As New FDBDataSet()
Dim FDBTableAdapter As New FDBDataSetTableAdapters.T_PicturesTableAdapter
For Each row As DataRow In FDBTableAdapter.GetData()
row.BeginEdit()
If row("id").ToString = 58672.ToString Then
row.BeginEdit()
Console.Write("Previous Value = " & row("ImgFileName").ToString)
row("ImgFileName") = "Tagada"
row.EndEdit()
Console.WriteLine(", Current Row Value = " & row("ImgFileName").ToString & " - HasChanges : " & FDBdataset.HasChanges())
End If
Next
FDBTableAdapter.Update(FDBdataset)
The output in the console is:
Previous Value = Aphidecta_obliterata_58672, Current Row Value = Tagada - HasChanges : False
I don't understand what is wrong and how to correct it... I would be very grateful for some help here !
TableAdapter seems set up correctly, and I can read from it, parse rows; display field values, etc... Update method reports as being correctly set up by the datasource designer. Code runs without errors but does not affect the DB content.
Why would you think that
FDBdatasethas any changes in it? Where are you making any changes to it? You have this:and
GetDatareturns a newDataTable, so you're making change to thatDataTablecompletely independent ofFDBdataset. Use one or the other but not both.Based on the code you have there, you don't need the
DataSet. You can just use theDataTablereturnd byGetData:Notice that I tidied up your code a lot too. If you're going to use a typed
DataSetthen use it.If you actually do need a
DataSetfor some reason then make the changes to it, not an unrelatedDataTable:That second code snippet may need some adjustments but I think it should work.
So, the moral of the story is that the
Fillmethod populates an existingDataTable, which can be part of aDataSetbut doesn't have to be, while theGetDatamethod creates a newDataTable, populates it and returns it. That newDataTableis not part of anyDataSet.