datasource updates not persistent

T

Ted

This is driving me nuts. I've tried everything I can think of. I'm
using VS.net2005 and I backtracked to trying code straight out of the
Microsoft "simple data application" tutorials with no luck.

I have a simple single table access database added to my project, drag
the datasource onto a form everything is created beautifully I can
navigate through the records, modify things, click the save button
etc... but no changes are ever written to the database. If I stop and
restart the app, I'm right back where I started. Below is the entire
form1 that was created by default, all I added was the try/catch and
messageboxes.


Public Class Form1
Private Sub MotorsBindingNavigatorSaveItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MotorsBindingNavigatorSaveItem.Click
Try
Me.Validate()
Me.MotorsBindingSource.EndEdit()

Me.MotorsTableAdapter.Update(Me.PartsdatabaseDataSet.motors)
MsgBox("Update successful")
Catch ex As Exception
MsgBox("Update failed")
End Try
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the
'PartsdatabaseDataSet.motors' table. You can move, or remove it, as
needed.
Me.MotorsTableAdapter.Fill(Me.PartsdatabaseDataSet.motors)

End Sub
End Class
 
A

AMDRIT

You can do a couple things to test for changes.

Here is one:

PartsdatabaseDataSet.GetChanges(added or modified or deleted) will return a
dataset with only the data that was changed. If this returns 0 rows, you do
not have any changes.

If you do have a rowset of changes, then use SQL Profiler (If you are
connecting to a SQL Database) and view the SQL statements that are being
issued to the SQL server. If there are none, then the table adapter isn't
detecting changes.

Try removing the Me.MotorsBindingSource.EndEdit() and the Me.Validate()
lines to see if anything changes.
 
T

Ted

You can do a couple things to test for changes.

Here is one:

PartsdatabaseDataSet.GetChanges(added or modified or deleted) will return a
dataset with only the data that was changed. If this returns 0 rows, you do
not have any changes.

If you do have a rowset of changes, then use SQL Profiler (If you are
connecting to a SQL Database) and view the SQL statements that are being
issued to the SQL server. If there are none, then the table adapter isn't
detecting changes.

Try removing the Me.MotorsBindingSource.EndEdit() and the Me.Validate()
lines to see if anything changes.


Thanks for the reply. I am using Access as the database, but I tried
the following:

Dim ds As DataSet = PartsdatabaseDataSet.GetChanges()

Me.MotorsTableAdapter.Update(Me.PartsdatabaseDataSet.motors)
ds = PartsdatabaseDataSet.GetChanges()

ds is set to something the first time, after the update it is set to
nothing, the update still is not persisted to the database (I removed
the validate and endedit with no luck) I get no errors.... I tried
rebooting no help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top