Connection strings and resource files

M

Mike P

I've always put my connection strings in the web.config, but I've just
recently seen an example of a connection string in a resource file.
What are the advantages of doing this, and could you do it for other
stuff that you would normally put in your web.config?
 
A

Andy

I've always put my connection strings in the web.config, but I've just
recently seen an example of a connection string in a resource file.
What are the advantages of doing this, and could you do it for other
stuff that you would normally put in your web.config?

There's not advantage, infact its a disadvantage. The connection
string is one of those things you'd like to be able to change without
recompiling the code. Put your string in a resource file, and you've
lost this ability. You also lose the ability to use connection string
encyption (if you're on .net 2).

Resource files are most useful for static strings (which an end user
may see), so that you don't have to hardcode them into code,
especially if you are going to localize your application. If you're
localizing, you simply create another resx file for the culture you're
targeting and translate all the strings there and you're done.
 
M

Mark Rae

I've always put my connection strings in the web.config,

Me too...
but I've just recently seen an example of a connection string in a
resource
file. What are the advantages of doing this,

None that spring readily to mind...

and could you do it for other stuff that you would normally put in your
web.config?

Sure - why not...?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top