1

I am having a real problem, I created multiple users in sql server with different dbroles, and now im trying to check what's the user role in db and connect to a connection string depending on their role as this will be more secure..... how can I choose between different connection strings and pass it to the model.edmx, remember I am working with 3 tier design.

here is how my login control works: http://i40.tinypic.com/nvz6lt.jpg

here is my connectionclass: http://i39.tinypic.com/34qmybs.jpg

here is my app.config file:

http://i43.tinypic.com/6xq4q8.jpg

Thanks alot

rene
  • 41,474
  • 78
  • 114
  • 152
Mazda
  • 85
  • 1
  • 1
  • 10
  • same question here ? http://stackoverflow.com/questions/8625347/how-to-choose-from-two-connection-strings/8625404#8625404 – Shyju Dec 24 '11 at 16:20

1 Answers1

2

There are multiple overloads for the ObjectContext constructor.

The default one just takes the connectionstring with a matching name from the config file. But you can also use a constructor where you specify the connection string yourself.

In your code you could maybe create a Authorization enum with values like BasicUser, Admin and pas that to your ConnectionClass. There you could do a switch and pick the right connection string from your config.

Wouter de Kort
  • 39,090
  • 12
  • 84
  • 103
  • thanks, but the problem is how to choose the right connection from the web.config file through c# asp.net... – Mazda Dec 24 '11 at 16:40