TableAdapterManager.UpdateAll does not save dataset to database

I decided to use the BindingNavigator for a newly created Windows forms application (built in VS2008 Standard), so I followed a tutorial (using drag & drop wizards) on doing so, step by step, but the underlying dataset is never committed to the database (SQL Express - MDF file) even though the UpdateAll method is called.  -

TableAdapterManager.UpdateAll does not seem to do anything

There are no errors, but opening the table shows that the data was never committed.

I've never using the Binding Navigator before (always did this in code, before, but would like to write apps a bit faster with these built in tools)

What am I missing here?


Private Sub OrderProcHeadersBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OrderProcHeadersBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.OrderProcHeadersBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DsOrderProcHeaders)  '<-- this line is hit in debug mode, but nothing is committed
    End Sub

Open in new window

bd9000Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Priest04Commented:
check on the HasChanges property of DsOrderProcHeaders just before the UpdateAll method
0
bd9000Author Commented:
I put this in to make sure it has changes, but the table remains empty    

   If DsOrderProcHeaders.HasChanges() Then
            Me.TableAdapterManager.UpdateAll(Me.DsOrderProcHeaders)
        End If
0
Priest04Commented:
does it execute this line? Put a breakpoint on it
Me.TableAdapterManager.UpdateAll(Me.DsOrderProcHeaders)

Open in new window

0
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

bd9000Author Commented:
Yes, it executes that line.  I wrapped it in a Try..Catch to see if any errors popped up.  There were no errors.

For kicks, I tried "Me.OrderProcHeadersTableAdapter.Update(Me.DsOrderProcHeaders)" instead - that also never updates the table.  

Could it be a setting in the DataSet?
0
Priest04Commented:
No, dataset shouldnt be the problem, since HasChanges reports true, then it has records that needs to be updated. What I could

When you say "but opening the table shows that the data was never committed.", do yyu mean that you open database (in sql server) and no data is there? How about when you reload the form, and load data though code, is data present then? I ask this because maybe you are working on a copy of database?

If not, do you have a primary key set for the table? And if you do, can you post a connection string you are using?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bd9000Author Commented:
   <connectionStrings>
        <add name="OrderProc.My.MySettings.OrderProcConnectionString"
            connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DB\OrderProc.mdf;Integrated Security=True;User Instance=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>

If I open the table (either in VS2008 or SQL Management Studio), the data is not there.
 The data remains in the dataset in memory except when any change is made to any form and re-compiled/run, then the memory/dataset is cleared.

The table has an identity field of type int that is also set as a primary key.

I checked the machine's event logs, and there is nothing reported w/regards to VS or SQL.
0
Priest04Commented:
I have never used user instances in sql server connection string, but I see in the examples that they all set initial catalog. I am not sure how much will this help, but maybe you should give it a try. I am not sure what exactly can be the problem here. If you want to exclude option that tableadapter is the problem here, you can create SqlDataAdapter in the update event, and rebuild Updte, Dele, and Insert COmmands, and try with it. If it also fails, then you know the problem is with connection string (I dont see what else can be the problem).

add this to connection string right before the Integrated Security=True;

Initial catalog=OrderProc;

and try also this code just to exclude tableAdapter
Private Sub OrderProcHeadersBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OrderProcHeadersBindingNavigatorSaveItem.Click
    Me.Validate()
    Me.OrderProcHeadersBindingSource.EndEdit()
    Dim da As New SqlDataAdapter(yourSelectQueryUsedToFillDataToDataSet, connection);
    dim cb as New SqlCommandBuilder(da);
    da.Update(Me.DsOrderProcHeaders)  '<-- this line is hit in debug mode, but nothing is committed
End Sub

Open in new window

0
bd9000Author Commented:
It turns out that VS2008 automatically creates an instance in both the bin\debug folder (when in debug mode) and in the bin\release folder (when in release).
The connection string was the clue "|DataDirectory|" needs to be replaced with the actual file path.

I'm not sure why MS decided to do this as a default behavior since most developers need to play with the data - having it erased and rebuilt is of no use nor is it of any use to have a separate debug database.
0
bd9000Author Commented:
My last comment, unfortunately, worked for a while, but now it does not update the friggin table.
Now, with 0 changes to the app, the UpdateAll method, once again, is NOT updating!

Anyone have any ideas on how to get around this friggin bug?!?!?!
No errors to go on, no way to debug, what the hell?!?!
0
bd9000Author Commented:
never mind again.  VS2008 changed the settings file to point to (yet again) the debug folder and copy the database there (yet again) without my knowledge.
Is there no way to tell VS to stop copying the database to the debug folder (or the release folder)?  
|Data Directory| always assumes this and always replaces my exact path in the application configuration.  Anyway to force the datadirectory to be a constant?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.