[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do I change an XSD connection string dynamically?

Posted on 2009-07-01
5
Medium Priority
?
1,332 Views
Last Modified: 2012-05-07
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.
0
Comment
Question by:richardhaeger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 15

Expert Comment

by:jinal
ID: 24759192
AS i understand you want to use diffrent connection string.

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.
0
 

Author Comment

by:richardhaeger
ID: 24759932
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.
0
 

Accepted Solution

by:
richardhaeger earned 0 total points
ID: 24768959
I also found this:

http://www.asp.net/learn/data-access/tutorial-72-vb.aspx

I believe my solution is here.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question