Re: Passing LINQ a Dynamic Connection String
I understand your suggestion, and your words in paragraph two are correct.
Here is the code you refer to inside my Linq data access layer (named AdminLinq):
Partial Public Class dcAdminDataContext
Inherits System.Data.Linq.DataContext
Public Sub New()
MyBase.New(Global.AdminLinq.My.MySettings.Default.AdminConnectionString, mappingSource)
OnCreated()
End Sub
Public Sub New(ByVal connection As String)
MyBase.New(connection, mappingSource)
OnCreated()
End Sub
From the calling UI application, with the connection string, I would like to do something like this:
AdminLinq.dcAdminDataContext(strAdminConnectionString)
However, I get this syntax error:
'dcAdminDataContext' is a type in 'AdminLinq' and cannot be used as a expression.
Or, if I instantiate a new AdminLinq data access layer and try to provide the connection string like thus:
Dim dalAdmin As New AdminLinq.linqAdmin(strAdminConnectionString)
I get a syntax error: "Too many arguments for Public Sub New()"
Were you thinking of something other than the above?
|