I have Users table in my database which stores usernames, passwords and other
information about users. When starting the application the user logs in
providing username and password.
This is why I want the connection string (including database username and
password) to be stored somewhere in code and not in application settings.
Only the program should "know" database username and password.
The database is accessed using both table adapters and command objects.
Which is the best place to store the connection string? How to specify this
connection string in existing table adapters?
Scott M. - 30 Dec 2006 21:51 GMT
I would still store the connection string in web.config and just inject the
user name and password into that string at run time. Remember, the string
is retrieved as just a string, so you can modify it in your code after
retrieving it.
There is no need for your code to have any information about the database
itself.
>I have Users table in my database which stores usernames, passwords and
>other
[quoted text clipped - 10 lines]
> this
> connection string in existing table adapters?
Miha Markic [MVP C#] - 30 Dec 2006 23:20 GMT
Hi John,
There are several solutions, such as:
- use integrated security
- separate data tier (so your app won't need connection string anymore)
- encrypt config file
What kind of application do you have?

Signature
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>I have Users table in my database which stores usernames, passwords and
>other
[quoted text clipped - 10 lines]
> this
> connection string in existing table adapters?