Where is best place to put DB connection string?

  • Thread starter Arvind P Rangan
  • Start date
C

Cowboy \(Gregory A. Beamer\)

Most people aim for web.config, but I would at least encrypt the string if
you do that. There are free books on ASP.NET security at
http://msdn.microsoft.com/architecture. Look at the "Patterns and Practices"
section.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
M

Max

Most people use the web.config, but it certain cases I've found it more
secure to just store it as a global variable within your app where it is
compiled.

-Max
 
K

Kevin Spencer

If you "store it as a global variable" it must be defined (read
"hard-coded") somewhere. I believe "where" was the question.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
M

Max

public class myvars
public shared strConnection = "blah blah blah happy now?"
end class

imports YourAppName.myvars

strConnection is now a variable you can use anywhere

Be careful what changes this variable as it is shared, and turn off page
errors so it doesn't bomb out and show your connection string to everyone.

-Max
 
C

Charlie@CBFC

Hi:

My ASP.NET app opens and closes database connection in several pages.
Rather than hard coding string into every page, is there a place I can put
it where all pages will be able to access it. In days of fat client
programming, I put in INI file. Looking for similar solution.

Thanks,
Charlie
 
M

Martin Dechev

Hi, Max,

As Kevin stated, with this technique the string is hard-coded, which in
other words means it is *not* configurable.

Greetings
Martin
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top