[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Best place to store connection string/class

Posted on 2004-10-11
4
Medium Priority
?
333 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

650 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