Data Access Block - Get con string from a webservice?

  • Thread starter Thread starter hillscottc
  • Start date Start date
H

hillscottc

My applications need to send a query to a WEBSERVICE to get the
configuration string they need for database access. Can any one suggest
how I modify the DAB to accomodate this?
 
Here is part of a method I wrote to get a database from a dynamic
connection string. I had to modify the DAB source files slightly too.

Dim iData As New InstanceData(ds.ID, "Sql
Server", ds.ID)
settings.Instances.Add(iData)

Dim connData As New ConnectionStringData(ds.ID)
' Just a unique ID for the connection

connData.Parameters.Add(New ParameterData("user
id", ds.UserID)) ' This data is
connData.Parameters.Add(New
ParameterData("workstation id", ds.WorkstationID)) ' the
connData.Parameters.Add(New ParameterData("data
source", ds.Server)) ' dynamic connection
connData.Parameters.Add(New
ParameterData("Password", ds.Password)) ' string data -
connData.Parameters.Add(New
ParameterData("initial catalog", ds.Database)) ' replace appropriately

settings.ConnectionStrings.Add(connData)

Dim configDic As New ConfigurationDictionary
Dim context As New
ConfigurationContext(configDic)

Dim dbf As New DatabaseProviderFactory(context)
db = dbf.CreateDatabase(ds.ID)
 
I see that Jason already answered you but let me make a recommendation if i
may. Connectionstrings are very bad candidates in general (I know, business
requirements often override this axiom) for retrieval anywhere but locally.
The reason I say this is b/c if you don't have internet connectivity in this
case, then you'll have issues. I had an instnace where I had the same
requirement you did once and we got into trouble b/c if the internet was
inaccessible, you couldn't run the app. So, what we ended up doing was
holding the connection string in a file and retrieving it from there, but
what we did was go to the WS and if we could hit it and make the webmethod
call, we'd overwrite the file value. Since the connection string seldom
changed, even ifyou couldn't hit the ws, chances are the db connectionsting
was still valid. This may not be valid if your db connection string is
volatile and changes a lot - but if it doesn't, then having something you
can safely default to is probably a good idea.

Bill.
 
I am having trouble understanding this code...the line breaks,
comments, and tabs seem to be scrambled. Where are you making the call
to a web service?
 
I am in a fairly large organization, and we have a central 'PASSWORD
STOREHOUSE' concept where all enterprise db configuration details are
centrally managed and encrypted. We have a wide variety of
applications, on a variety of servers, needing to get configuration to
a variety of SQL Servers. We manage all this in one place, and provide
access via a webservice.
 
Back
Top