Solved

Datasource Practices - ASP.NET connecstring

Posted on 2004-10-04
1
516 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

710 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