Link to home
Start Free TrialLog in
Avatar of TimSweet220
TimSweet220

asked on

VB App - Connection to SQL

I have a VB.net that while in the development environment was connected up to a development database.  Now that the app is being moved to the production environment the connection has to changes.

Here is my problem:   All of the DataAdapters were created with the Wizard and that included the connection string.   There are 100's of adapters.

How can I change these?

If this were a web app I would have a reusable piece of code that would be called and the move to Production would only take a quick change to the connnection string in that code and not have to touch all the pages....is there the ability to do that in VB.net?

If I'm going to have to touch all the pages I'd rather add something like this rather than change the dbname.

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of ptakja
ptakja
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TimSweet220
TimSweet220

ASKER

Here is what I ended up doing.

Editing the appconfig file to like so:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
      <appSettings>
            <!--   User application and configured property settings go here.-->
            <!--   Example: <add key="settingName" value="settingValue"/> -->
            <add key="txbPGY.ReadOnly" value="False" />
            <add key="ColProgramYear.Text" value="Program Year" />
            <add key="ColProgramYear.Width" value="77" />
            <add key="ColStart.Text" value="Start Date" />
            <add key="ColCredit.Text" value="Credit" />
            <add key="ColVacDays.Text" value="Vac Days" />
            <add key="ColDateSent.Text" value="Date Sent" />
            <add key="ColTrain_Id.Text" value="Train_ID" />
            <add key="ColReference_Id.Text" value="Reference_ID" />
            <add key="SqlSelectCommand2.CommandText" value="dbo.[sp_GetRefData]" />
            <add key="ColRotationDesc.Text" value="Rotation Description" />
            <add key="ColWeeks.Text" value="Weeks" />
            <add key="ColEvaluation.Text" value="Evaluation" />
            <add key="ColTrainingYear.Text" value="Training Year" />
            <add key="ColTrainingType.Text" value="Training Type" />
            <add key="ColStartDate.Text" value="Start Date" />
            <add key="ColEndDate.Text" value="End Date" />
            <add key="ColumnHeader213.Text" value="TrackTitle" />
            <!-- Minime Connection -->
            <!--add key="ABRConn" value="workstation id=AD072;packet size=4096;user id=sa;data source=Production;persist security info=True;database=dbblah;password=blah" -->
            <!-- Smallme Connection -->
            <add key="ABRConn" value="workstation id=AD072;packet size=4096;user id=sa;data source=DEV;persist security info=True;initial catalog=dbblah;password=blah" />
      </appSettings>
</configuration>

then at the time of creating the build to distribute comment out the DEV source and UNcommenting the Production.

In the code we use this piece of code to set the connection

 'SqlConnection1
        '
        Me.SqlConnection1.ConnectionString = AppSettings.Get("ABRConn")



This works great.

however...it eliminates the use of the DataAdapter wizard because changes there remove the code in the above code InitializeComponent  - sure why.