?
Solved

Best place to store connection string/class

Posted on 2004-10-11
4
Medium Priority
?
332 Views
Last Modified: 2008-02-01
I'm building an asp.net website.  
For the asp.net web pages that need a connection string, I can put the connection string in the web.config file and use it/change it as needed.  I was planning on creating a few separate projects for the reusable parts, so was going to create a few stand alone components.  However, the vb.net project does not have a web.config file, so where is the best place to store the connection string?

Also saw a friend put classes within a folder in his asp.net web project.  He was able to use web.config to store his connection string.  Is that a good idea?

Thanks for any help.
0
Comment
Question by:davexxxx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 4

Accepted Solution

by:
eozz_2000 earned 200 total points
ID: 12281834
I store the connectionString of my connections in a file stored in a folder that is not visible to the users that acces my application.
0
 
LVL 16

Assisted Solution

by:MikeMCSD
MikeMCSD earned 200 total points
ID: 12427818
Web.config is the best place:

<configuration>
<appSettings>

<add key="ConnectionString"
        value="server=localhost;Trusted_Connection=true;database=DCP"/>

</appSettings>
.......

then put this in your code:

Private Shared ReadOnly Property connectionString() As String
        Get
            Return ConfigurationSettings.AppSettings("ConnectionString")
        End Get
    End Property

and to use it, just add the variable:

Dim connection As New SqlConnection(connectionString)
..
..

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question