Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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

Posted on 2009-05-18
Medium Priority
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.  
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

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 1500 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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.   …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

604 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