Programmatically change query connection string

bntringa

New member
Joined
Jun 19, 2007
Messages
4
Programming Experience
5-10
Hey all,

Hopefully a quick, dumb question. I've got some code that executes a query but need to programmatically change the connection string from the default that was used to originally create the query. The query in question below is CreateTableLog. Would like to modify the .ConnectionString property if possible.

Thanks!

- Brian

VB.NET:
Friend Function CreateLogTable() As Boolean
        Try
            Dim dtQueries As New dsLogTableAdapters.LogQueriesTableAdapter

            dtQueries.CreateTableLog()

            Return True

        Catch ex As Exception
            HandleError(ex, "modDbMaintenance.CreateLogTable")
            Return False
        End Try
    End Function
 
VB.NET:
dim database as string = "C:\Database.mdb"
dim strConn as string = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & database
YourTableAdapter.Connection.ConnectionString = strConn
 
If alander's code doesnt work (the member might be private) come back; there's a way to change connection strings app-wide but it's not recommended for newbies
 
there's a way to change connection strings app-wide but it's not recommended for newbies

He's not lying there! Did you get this sorted? I change my connection string on a popup, it's not easy, it's dirty programming, but it works!
 
Back
Top