richardhaeger
asked on
How do I change an XSD connection string dynamically?
Hello,
I have an ASP.NET Web site.
I have a "MyCS" connection string in my web.config.
I have a "MyDS" dataset in my App_Code.
In MyDS I have created several table adapters using MyCS.
Now in real life I have multiple databases, all equal in design (same tables and relationships) but with different data (each belonging to a different customer).
Alll customers use the same web, but each must connect to their own database. So after an user logins I retrieve a profile value containing the name of the database he is supposed to connect to. But...
How do I change MyCS dynamically so that each user connects to his/her own database?
Thanks in advance.
I have an ASP.NET Web site.
I have a "MyCS" connection string in my web.config.
I have a "MyDS" dataset in my App_Code.
In MyDS I have created several table adapters using MyCS.
Now in real life I have multiple databases, all equal in design (same tables and relationships) but with different data (each belonging to a different customer).
Alll customers use the same web, but each must connect to their own database. So after an user logins I retrieve a profile value containing the name of the database he is supposed to connect to. But...
How do I change MyCS dynamically so that each user connects to his/her own database?
Thanks in advance.
ASKER
Thanks for answering jinal but I can't do that.
As I said, in my dataset I have several table adapters I made with the table adapter wizard. The table adapter wizard asks for a connection string as the first step in the wizard. If I check the XSD code, I can see the wizard generated all the code for my table adapters using "MyCS" as connection string. If I define several connection strings, and change the connection string dynamically as you suggest, my XSD still pulls all the info from the connection string that it was created with. So what I need to do is change that CS dynamically, not change to another connection string.
I found this (exactly my problem):
http://stackoverflow.com/questions/435444/changing-xsd-connectionstring-at-runtime-for-a-multitenant-app
I'll try it tomorrow.
As I said, in my dataset I have several table adapters I made with the table adapter wizard. The table adapter wizard asks for a connection string as the first step in the wizard. If I check the XSD code, I can see the wizard generated all the code for my table adapters using "MyCS" as connection string. If I define several connection strings, and change the connection string dynamically as you suggest, my XSD still pulls all the info from the connection string that it was created with. So what I need to do is change that CS dynamically, not change to another connection string.
I found this (exactly my problem):
http://stackoverflow.com/questions/435444/changing-xsd-connectionstring-at-runtime-for-a-multitenant-app
I'll try it tomorrow.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Either store all connection string for each of customer in web.config.
Or Create one database that is common to all customer and this database contain all information about customer . In that information keep database connection string.
So runtime retrieve that connection string and use in xsd connection string.