Where to store DB connection string?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, friends,

I have two questions:

(1) In asp.net, where is the best place to store DB connection string? (We
have .dll to handle all DB queries.)

(2) Any sample source code for client side calendar? (We tried web control
calendar. But, each time we selected a date/changed year or month, it would
go back to web server. It would increase a lot network traffic.)

Thanks a lot.
 
Andrew,

The best practices state to store the connection string in the appSettings
section of the web.config file.

I don't have a recommendation for a calendar, I hope someone else will be
able to steer you in the right direction for that.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Hello Dear Andrew,

Answer to your 1st Question
(1) In asp.net, where is the best place to store DB connection string? (We
have .dll to handle all DB queries.)

In the web.config just add the <appSettings></appSettings> in between
<configuration> and <system.web> like the following
<configuration>
<appSettings>

<add key="ConnectionInfo"
value="server=(local);database=Northwind;Integrated Security=SSPI" />

</appSettings>
<system.web>

give a Key Name for example I have given it as "ConnectionInfo" and the
value as your database details.

Thats all in the web.config.

In you code-behind file, to retrieve the Connection Info use
ConfigurationSettings.AppSettings

for example:

string connectionInfo = ConfigurationSettings.AppSettings["ConnectionInfo"];

using(SqlConnection connection = new SqlConnection(connectionInfo))

Try this one, It will work.

Reply to the 2nd Question, I will come back to you
(2) Any sample source code for client side calendar? (We tried web control
calendar. But, each time we selected a date/changed year or month, it would
go back to web server. It would increase a lot network traffic.)

bye
venkat_kl
 
Back
Top