How to change connection string in DataSet.xsd?

68,385

Solution 1

When generating a DataSet with the Wizard you are asked to Create-and-Store a ConnectionString. Take a look in your App.Config

Solution 2

You can also open the Dataset and select the TableAdapter that you want to update, right click and go to properties.

here you will see a "connection" property that you can easily change to settings in your web.config file or enter new connection details.

Solution 3

I had similar situation... I'd already created lots of datasets, and they each recorded their own connection string in the code behind. A also manually interacted with database via connectionstring I'd placed in App.config file. So to update all this when deploying to as-yet-unknown server would be pain; yet manually changing all those connectionstrings also put me off. In the end I added a 'test' tableAdapter to the .xsd design page... and created a New connection string - this time specifying it be placed in App.config file. Then by magic... all the tableAdapters now used this one connectionstring - just delete the test object & voila!

Solution 4

For WinForm its very simple. please refer below picture enter image description here

Solution 5

You can using like my code: Note that DataSet can change connection string by app.config but you can change connection string by TableAdapter like below:

NCKHSV_TTD54TableAdapters.adtReportGiangVienTableAdapter tableAdapter = new 
NCKHSV_TTD54TableAdapters.adtReportGiangVienTableAdapter();//Create a TableAdapter to using.
 tableAdapter.Connection.ConnectionString = strConn;//change ConnectionString to strConn
 tableAdapter.ClearBeforeFill = true;
 tableAdapter.Fill(dataset.adtReportGiangVien);
Share:
68,385
Gold
Author by

Gold

Updated on December 16, 2020

Comments

  • Gold
    Gold over 3 years

    I have build my project in C#, I add DataSet.xsd, and connect him to

    Oracle DataBase in my computer - work Excellent !!!!

    When I installed on the customer computer (that connect to his Oracle DataBase) -

    it crushed.

    I need to change the connection string on the DataSet.xsd file - but how to do it ?

    Is there any xml file ? Or configuration file ?

    Thanks in advance.

  • Trio Cheung
    Trio Cheung about 11 years
    I am using Visual Studio 2012. I want to change the connection string to my remote web server. But I don't have direct access to the web server. The wizard does not allow my to add the adaptor. How can I change the connection string manually?
  • Cheshire Cat
    Cheshire Cat over 9 years
    What if I need to encrypt the connection string? I have a similar problem, except that I want to use the encrypted connection created with the aspnet_regiis method and already stored on the app.config file. My Dataset.xsd still uses the ConnectionString stored on the Settings.settings file, automatically added with the Wizard.
  • Cheshire Cat
    Cheshire Cat over 9 years
    Is this solution applicable on my .NET 4 Windows Form application if I want to use an encrypted connection string stored on the app.config file?
  • Henk Holterman
    Henk Holterman over 9 years
    Don't ask follow-ups in comments. Look for it and when you can't find it post a regular question.
  • Cheshire Cat
    Cheshire Cat over 9 years
    Yes, you're right! And since I haven't found an answer I asked my own question. :-) stackoverflow.com/questions/26734610/… Please take a look if you want!