Dear All,

I have developed a web site using asp.net and C#,
Iam using Microsoft enterprise library - DBfactory for establising connection with sql server 2005.

Now i want to implement the application to connect to different databases for different users.

For example

Client A should connect to database DB1 in Server-1

Client B should connect to database DB2 in Server-2

Client C should connect to database DB3 in Server-3

        .
        .
        .

For this purpose, from client i can pass connection string as a query string.

Now i dont know how to implement this, iam using enterprise library DBFactory, Please give me a solution as early as possible.

Thanks in advance,

Regards,
Vasanth.

Recommended Answers

All 3 Replies

Passing a connection string as a query string is extremely Dangerous...

Passing a value of 1,2,3 or a,b,c which maps to a corresponding connection string is much safer.

Microsoft enterprise library methods take a connection string as a paramter, so pass them all a variable of say strConnectionString,
and on page load do a select case on your query string parameter to set strConnectionString = to the proper connection string.

Dear agrothe,

Thanks for your reply,

iam avoiding the connection string as query string,
Now my problem is, when 2nd client login with another connection string, the 1st client connection is closed.

so i want to keep alive the 1st client connection. How to keep others connection.

Please replyl me,

Thanks & Regards,
Vasanth.

You need a new connection object for each database. If you aren't using classes, just have three recordsets, one for each database.

I'm sure there is a better way to do all of this, but without examining the code it's hard to say the best way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.