VB2008: ConnectionString in strongly typed TableAdapter

  • Thread starter Etienne-Louis Nicolet
  • Start date
E

Etienne-Louis Nicolet

I'm working on an application where the user should be able to log on to
different databases (test database, production db, etc.).

Since in my TableAdapter classes I have the choice to either hard code the
connection string in the class or to store the connection string in the
(read-only) application settings, I see way to have the user change these
settings during execution of the application.

I therefore created a user setting with the connection string (as string)
and added a method to every single TableAdapter which i have to call
whenever i instantiate a TableAdapter:

Public Sub SetConnectionString
' My.Settings.MyConnectionString is set when the user logs on to the
database
Me.Connection.ConnectionString = My.Settings.MyConnectionString
End Sub

In order to overcome this repetitive task of adding the above method to
every Adapter I'm looking for a way to create a class which handles this
task for all TableAdapters. Does anybody have an idea how to approach the
problem?

Many thanks for any suggestions,
Etienne
 
M

Miro

I always had the same issues, and kept it on the back burner for about a
year ...and stumbled upon that video and thought I had struck gold.

If they only would mention something like that in the msdn documentation or
something... why they make the connection string read only still annoys me.

At least this work around gets around it. -Still annoying

Cheers'

Miro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top