davy_g
Well-known member
Hi all,
I have created a little app that can view, delete, insert and update records in a SQL Server Db.
My current problem is that when I update a record I sill get the old record when I scroll to it again.
I only get it updated when I close and newly open this screen.
I know that the cause is that my dataset still has these old data, so I should renew my dataset in order to get the new data.
For reading the data in the screen I have following code:
Then comes my update which works excellent. After this I want to refresh my dataset to immediately show my updated values so I can freely scroll in the records.
I have the following code for this:
It does not seem to work. I see my change directly disappear.
When I newly open my screen I have my value back again.
Oh the "inc" is just a counter which knows in which record I am working.
I've read something about disposing my dataset and then newly read it but this does also not work.
I would set ds.Dispose() in front of the rest of the code.
Is disposing an item clearing it from the memory (what they call the garbage collection?)?
Can anybody help me? What am I doing wrong?
Thanks
I have created a little app that can view, delete, insert and update records in a SQL Server Db.
My current problem is that when I update a record I sill get the old record when I scroll to it again.
I only get it updated when I close and newly open this screen.
I know that the cause is that my dataset still has these old data, so I should renew my dataset in order to get the new data.
For reading the data in the screen I have following code:
VB.NET:
Dim con As New SqlConnection
Dim ds As New DataSet
Dim da As SqlDataAdapter
Dim sql As String
con.ConnectionString = "bla bla"
con.Open()
sql = "SELECT id, naam FROM adressen"
da = New SqlDataAdapter(sql, con)
da.Fill(ds, "Adres")
con.Close()
txtId.Text = ds.Tables("Adres").Rows(0).Item(0)
txtNaam.Text = ds.Tables("Adres").Rows(0).Item(1)
Then comes my update which works excellent. After this I want to refresh my dataset to immediately show my updated values so I can freely scroll in the records.
I have the following code for this:
VB.NET:
con.Open()
da = New SqlDataAdapter(sql, con)
da.Fill(ds, "Adres")
con.Close()
txtId.Text = ds.Tables("Adres").Rows(inc).Item(0)
txtNaam.Text = ds.Tables("Adres").Rows(inc).Item(1)
It does not seem to work. I see my change directly disappear.
When I newly open my screen I have my value back again.
Oh the "inc" is just a counter which knows in which record I am working.
I've read something about disposing my dataset and then newly read it but this does also not work.
I would set ds.Dispose() in front of the rest of the code.
Is disposing an item clearing it from the memory (what they call the garbage collection?)?
Can anybody help me? What am I doing wrong?
Thanks