Solved

Datasource Practices - ASP.NET connecstring

Posted on 2004-10-04
1
517 Views
Last Modified: 2008-03-04
Hi,

i have a db connection like this

dbpath="d:\database\data\CRM.mdb"
username="admin"
password="password"

then connecstring of

            Me.pvtConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" _
                      & "User ID=" & Me.username& ";" _
                      & "Data Source=" & Me.dbpath& ";" _
                      & "Jet OLEDB:Database Password=" & Me.password& ";"

Before, when i run asp (developed using dreamweaver), i could just change the dbpath to sumthing else.
Now, i have converted it to VB.net asp project.
now i cant change the DBpath anymore, i have to recompile and deploy it back to the server.

How do you guys do it?
best practices?

0
Comment
Question by:Jerry_Pang
[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
1 Comment
 
LVL 3

Accepted Solution

by:
skpatra earned 250 total points
ID: 12215782
You have configuration files in .net applications. Config files provide coniguration information at runtime and the great thing about the config files is that you can change the configuration information without recompiling the program. So here are the steps:

1. In your VB.Net application, open the web.config file. If you are not using VS.Net, then just add a file called web.config under the root directory of your website.  It should lok something like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
   .
   .
   .
  </system.web>
</configuration>

2. Now, add your DBPath as a configurable parameter under a tag called appSettings.

<configuration>
  <system.web>
   .
   .
   .
  </system.web>
  <appSettings>
    <add key="DBPath" value="d:\database\data\CRM.mdb" />
  </appSettings>
</configuration>

3. In your code you can read this value as
    dbpath = System.Configuration.ConfigurationSettings.AppSettings.Item("DBPath")

Now, you can change the value of DBPath in the web.config file without recompiling the application. Refer to the following url for a detailed demo of the configuration files.

http://samples.gotdotnet.com/quickstart/aspplus/doc/configretrieve.aspx

Hope this helps...
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
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…

626 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