I have been trying to set the connection string at run with variations of this:
in VB2008 are we able to do this?Code:Option Strict On Option Explicit On Public Class payments Private Sub payments_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cConString As String = (My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\dir\expressAccountsDB.mdf;Integrated Security=True;User Instance=True") PaymentsTableAdapter.Connection.ConnectionString = (cConString) 'TODO: This line of code loads data into the 'ExpressAccountsDBDataSet.payments' table. You can move, or remove it, as needed. Me.PaymentsTableAdapter.Fill(Me.ExpressAccountsDBDataSet.payments) End Sub End Class
I have read almost everything on doing this and i am unable to get it to work.
This is what my connection looks like in setting at the moment:
and this is from the app.config file:Code:Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\expressAccountsDB.mdf;Integrated Security=True;User Instance=True
Code:<connectionStrings> <add name="expressAccountsDB.My.MySettings.expressAccountsDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\expressAccountsDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" /> </connectionStrings>
I have tried numorus variation of the above from the many examples i have came across but i was unable to get any working.




Reply With Quote