.NET 2.0 TableAdapterManager Does Not UPdating backend Database-I must be missing something basic

Posted on 2009-05-18
Last Modified: 2013-11-26
Very similar to post:

I'm building a Windows Application and attempting to migrate my skill-set from manually coding SQL Add/Update/Delete to using the databinding functionality in VS 2008. I have a small table of Users in SQL Server Express which I attempt to update from a form. The data changed are excepted on the screens and changes are redisplayed as I navagate away and back to the records again. Also, from debug, I can see the values in the DataSet are changing.
However, when I press the update button, and the TableAdapterManger.UpdateAll(me.DSusers) executes (no exeptions or errors) but the back end data base is unchanged. After reading several related issues I am:
Including a manual call to BindingSource.EndEdit()
If a duplicate set of data is being used in Debug, I can't find it.

Please Help me determine the problem so that I can move forward in my project.  



        Catch ex As Exception

            MsgBox("Error on UPDATE - (" & ex.Message & ")")

        End Try


Connection String = Data Source=CDS001\ICEXPRESS;Initial Catalog=ICExpress;Persist Security Info=True;User ID=icexpress;Password=jack08;

Open in new window

Question by:mpharis
  • 7
  • 5
LVL 41

Expert Comment

ID: 24441265
Take a look at the TableAdapter's properties....   you should be able to see the automatically-generated INSERT, DELETE, and UPDATE commands.
Also, if you're just using one table, you probably don't need to use the TableAdapterManager (as that was designed to perform the Update() method on each TableAdapter in the correct order... something that a bit of overkill if you've just got one TableAdapter).   So, just for the sake of simplifying your example, let's change that line to use the TableAdapter's update method.   It would look something like this:
... just guessing on the name of the TableAdapter!

Author Comment

ID: 24441865
Thanks, I'll give it a try later today and report the results. Thanks for the reply.

Author Comment

ID: 24445797
ARGH!!!  This is very frustrating and I know I'm overlooking something simple.
I looked at the UPDATE commands in the properties of the TableAdapter and it looked fine. I replaced the TableAdapterManager with the TableAdapter and attempted an update. Still same results. Looks like good in the Application and Data set. I can advance to other records and them come back to the one I changed and it shows the changes. However, when I end DEBUG and the start the application again in DEBUG the changes are not there.  I just verified that when I execute the UPDATE command in the application, instead of exiting I when into the SQL Database and the backend data did not changed. I am not using a database file in the project/solution. I'm using a stand alone SQL Express database which exists outside of my project. I don't understand but is there any way that VS2008 is creating a temporary version of the database each time I enter debug and if so, how can I tell it or control it.  
Once again. Thanks in advance. Any info and/or direction you can give is greatly appreciated.  
LVL 41

Expert Comment

ID: 24445955
Show us the generated connection string (also from the TableAdapter's properties), just to verify that VS2008 didn't somehow switch you over to a database file.

Author Comment

ID: 24447328
Connection string from the tabeadapter propery:
Data Source=CDS001\ICEXPRESS;Initial Catalog=ICExpress;Integrated Security=True

I am manually resetting the connection string and loading the tableadapter in he Form Load event using the following code:
        stmnt = "SELECT userid, currentco, currentbu, admin, userDescription, createdtimestamp, " & _
            " defaultco, defaultbu, rrn, active FROM dbo.Users"
        Dim DAusers As New SqlDataAdapter(stmnt, con)
        DAusers.Fill(DSusers, "Users")
This uses the connection string specified in the original post. It happens to be the same as the connection string property because this is the test sytem.
Looks like the only difference in the connection string is the change from integrated security to requiring credentials.

LVL 41

Expert Comment

ID: 24447388
I think we're getting somewhere...   in the short example above, you're actually using two different techniques together...   the "traditional way" of using a DataAdapter to fill the table, but then you switch to using TableAdapters afterwards...    to fill the same table over again?
I'd suggest that  you stick to just one techique...
  • DataAdatper.Fill()
  • ... do something with the locally-cached DataSet
  • DataAdater.Update()
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.


Author Comment

ID: 24447438
That makes sense. How do I make the connection string dynamic for deployment to different clients and databases. My current technique (obiviously not fully tested) is to use the local database for development and call a custom class in the Page_Load event which retrieves the specific client connection string and attempts to re-bind/re-fill the datasets. That was my intended purpose above. What is the best way to make the application connection portable?
LVL 41

Expert Comment

ID: 24449736
Most folk put the connection string in the web.config file.... that way you'd just have to change it in one place and the change would appear in all of the pages. 

Author Comment

ID: 24450319
Thanks for all the input graye. However, this is a windows form application so there is no web.config file and unfortunately the Connection String Application setting is "ReadOnly" so I can't dynamically change it there. Your input is much appreciated in this area but I suppose I need to get back to the focus of the original Post. I've tried going back to simply using the TableAdapter to update but still have the same results. DataSet gets updated in on screen but no Error messages or any indication of anything wrong but... backend data not updated.
I don't want to upload the whole VisualStudio solution/project; what can i provide to help nail down the issue. It is almost like the DataSet is not Bound to the backend database. I have relatively good confidence that the issue is not a copy or temporary database created at debug time. I've configured the application to display the connection info to the form at time of update and all looks well at that point.

I am attempting to reset the data connection to the client database like we discussed previously but have empoyed a different approach which fills the dataset and appears to be working fine (but again, this may be the area that's causing the problem)

Author Comment

ID: 24450388
I removed any additional code and simply used the connection defined in the wizard with the table adapter. Same results. DataSet appears to update but database is unchanged.
LVL 41

Accepted Solution

graye earned 500 total points
ID: 24453454
OK... let's start at the beginning.   Let's get the dang thing running, and then we'll add to it until we figure this out.
I propose that you start over with hand-coding the DataAdapter and DataSet without the use of any wizard or designer at all.    As I've said... let's get it to work first
Take a look at the following artciles on how to use ADO.Net without wizards or designers

Author Comment

ID: 24454315
I appreciate your help mr. gray.  I'm not where i can look at this right now but will work through it over the week end. Please continue to check on my progress as you have time and i'll post results over the weekend. thanks

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
Why, and when, to use Windows Workflow 1 31
Export import database 4 41
Visual Studio 2015 Source Code Control 10 26
Javascript and Jquery not firing 9 37
IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 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

19 Experts available now in Live!

Get 1:1 Help Now