.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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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.  
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

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()

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

Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash ( has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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