Refuses to load data from sql database


Well-known member
Oct 11, 2008
Programming Experience
I have a windows form application where I use an internal database mdf-file.
I have then altered the runtimeConnectionstring to be able to choose what database to load the data from.

I have made a copy of the local database into the sql-server and checked my connection and it works.
Even if I set the RuntimeConnecrionString to connect to the sql server the application still gets it's data from the local database-file.
Anyone know why that is?

This is my connectionstring
     DS2 = "Data Source=" + TextBox1.Text + ";Network Library=DBMSSOCN ;Initial Catalog=" + TextBox2.Text + ";User ID=" + TextBox3.Text + ";Password=" + TextBox4.Text + ""
    connetionString = DS2

This is the code in my settings
    Namespace My
    'This class allows you to handle specific events on the settings class:
    ' The SettingChanging event is raised before a setting's value is changed.
    ' The PropertyChanged event is raised after a setting's value is changed.
    ' The SettingsLoaded event is raised after the setting values are loaded.
    ' The SettingsSaving event is raised before the setting values are saved.
    Partial Friend NotInheritable Class MySettings
    Public WriteOnly Property RuntimeConnectionString() As String
    Set(ByVal value As String)
    My.Settings("QAConnectionString") = value
    End Set
    End Property
    Private Sub MySettings_SettingsLoaded(ByVal sender As Object, ByVal e As System.Configuration.SettingsLoadedEventArgs) Handles Me.SettingsLoaded
    End Sub
    End Class
    End Namespace

Then in my main form I use this code to set det connectionstring:

     My.Settings.RuntimeConnectionString = Start.DS2
Top Bottom