|
-
Feb 15th, 2011, 11:44 AM
#1
Thread Starter
New Member
vs2010 update tableadapter connection string (dynamically) - pls help
Hi Everyone.
I am working on a program using WinForms in VS2010 and SQL Server 2008 as backend database. I know my endusers will not have the same connection string for the database as I will. I've done research and figured out how to design a form that takes user information in textboxes for the connection string information (server name, authentication, database, etc). This information is written to an xml file. In the settings.vb tab of project settings, I have viewed the code and created a User String called MyConnectionString. In the code view, I have set things up to set the original connection string to now use my user-defined string. This appears to work correctly and the XML file saves. My understanding is that when I load my main form, I am supposed to read/load the XML file and then call My.Settings with the name of my user-defined connection string before any TableAdapter Fill() commands.
As I have a database created for my program, I create datasets and then drag the fields that I need onto my forms - this creates the dataset, binding source, table adapters, etc. In order to test everything out, I have created a simple test project with a few forms, and used the Contact field of the AdventureWorks database. The dataset for this can be viewed in the designer. Creating the dataset creates a connection string (which should be able to be changed based on reading/loading the XML file & calling My.Settings before the TableAdapter Fill() command.).
If I leave the tableadapter fill code alone, the adventureworks contact form loads data with no issues. If I try and make any changes, nothing happens (even if i use the user input form and set the database for adventureworks). I have set the connection modifer on the table adapter to public. I have made a call to My.Settings, I have tried using partial classes of the table adapter to tell it to use my user-defined connection string.
Does anyone have any idea what I might be missing and how to make this work? Or do I need to post samples of the code I have used or let someone view the basics of my VS2010 solution?
Would really appreciate help with this.
Thank you,
Kelly
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|