473,378 Members | 1,507 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Physcial Path of Reference

Al
Greetings,

I have several data access class libraries referenced by a web project. I'm
storing the connection string in the data access libraries. I would like an
easier way of moving from my local database server to the production
database than loading every library, changing the connection string to
reflect the new database server address, and recompiling

Since only the database server address would change. I was thinking of
storing the desired database server address in an xml file located in the
bin directory with the other references. When a database call is made, the
correct server address is retrieved from the xml file. However, unlike web
projects, it seems difficult for a class library to determine where it's
located.

Any ideas?

My other concern is the frequency of file operations on the XML file. Any
other ideas.

Thanks in advance.

--
Regards,

Al
Nov 17 '05 #1
6 996
web project don't really run from the bin, it copied to temp bin (and
referebced dlls), then compiled, so knowning dir would not be much good, but
you get it from the assembly classes.

put the connection string in the web config (or appconfig if windows app).

-- bruce (sqlwork.com)
"Al" <gt*****@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP12.phx.gbl...
Greetings,

I have several data access class libraries referenced by a web project.
I'm storing the connection string in the data access libraries. I would
like an easier way of moving from my local database server to the
production database than loading every library, changing the connection
string to reflect the new database server address, and recompiling

Since only the database server address would change. I was thinking of
storing the desired database server address in an xml file located in the
bin directory with the other references. When a database call is made,
the correct server address is retrieved from the xml file. However,
unlike web projects, it seems difficult for a class library to determine
where it's located.

Any ideas?

My other concern is the frequency of file operations on the XML file. Any
other ideas.

Thanks in advance.

--
Regards,

Al

Nov 17 '05 #2

"Bruce Barker" <br******************@safeco.com> wrote in message
news:ud*************@TK2MSFTNGP14.phx.gbl...
web project don't really run from the bin, it copied to temp bin (and
referebced dlls), then compiled, so knowning dir would not be much good,
but you get it from the assembly classes.

put the connection string in the web config (or appconfig if windows app).

-- bruce (sqlwork.com)
"Al" <gt*****@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP12.phx.gbl...
Greetings,

To further explain:

Modify your web.config to add the appSettings section:

<configuration>
...
<appSettings>
<add key="ConnectionString"
value="server=PRODUCTION;database=dbDatabase;trust ed_connection=true;" />
</appSettings>
</configuration>
Use something like the following to retrieve the ConnectionString from code:

using System.Configuration;

namespace YourName.Space.Here
{
internal sealed class Configuration
{
private static string mConnectionString;

internal static string ConnectionString
{
get {
return
ConfigurationSettings.AppSettings.Item("Connection String");
}
}
}
}

btw, off the top of my head here.

HTH,
Mythran

Nov 17 '05 #3

"Bruce Barker" <br******************@safeco.com> wrote in message
news:ud*************@TK2MSFTNGP14.phx.gbl...
web project don't really run from the bin, it copied to temp bin (and
referebced dlls), then compiled, so knowning dir would not be much good,
but you get it from the assembly classes.

put the connection string in the web config (or appconfig if windows app).

-- bruce (sqlwork.com)
"Al" <gt*****@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP12.phx.gbl...
Greetings,

To further explain:

Modify your web.config to add the appSettings section:

<configuration>
...
<appSettings>
<add key="ConnectionString"
value="server=PRODUCTION;database=dbDatabase;trust ed_connection=true;" />
</appSettings>
</configuration>
Use something like the following to retrieve the ConnectionString from code:

using System.Configuration;

namespace YourName.Space.Here
{
internal sealed class Configuration
{
private static string mConnectionString;

internal static string ConnectionString
{
get {
return
ConfigurationSettings.AppSettings.Item("Connection String");
}
}
}
}

btw, off the top of my head here.

HTH,
Mythran

Nov 17 '05 #4
Al
Greetings,

I was unaware that web.config files could be used in class library projects.
I'll have to try this.

But, each of the data access libraries points to a different SQL database,
on the same database server. Also, some of these data access libraries are
used by more than one project. If I store the predominant connectionstring
in the .config file of the web application, how do I pass that on to the
data access libraries.
Thanks in advance.

--
Regards,

Allen Anderson
"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

"Bruce Barker" <br******************@safeco.com> wrote in message
news:ud*************@TK2MSFTNGP14.phx.gbl...
web project don't really run from the bin, it copied to temp bin (and
referebced dlls), then compiled, so knowning dir would not be much good,
but you get it from the assembly classes.

put the connection string in the web config (or appconfig if windows
app).

-- bruce (sqlwork.com)
"Al" <gt*****@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP12.phx.gbl...
Greetings,

To further explain:

Modify your web.config to add the appSettings section:

<configuration>
...
<appSettings>
<add key="ConnectionString"
value="server=PRODUCTION;database=dbDatabase;trust ed_connection=true;" />
</appSettings>
</configuration>
Use something like the following to retrieve the ConnectionString from
code:

using System.Configuration;

namespace YourName.Space.Here
{
internal sealed class Configuration
{
private static string mConnectionString;

internal static string ConnectionString
{
get {
return
ConfigurationSettings.AppSettings.Item("Connection String");
}
}
}
}

btw, off the top of my head here.

HTH,
Mythran

Nov 17 '05 #5

"Al" <gt*****@hotmail.com> wrote in message
news:Ol*************@TK2MSFTNGP12.phx.gbl...
Greetings,

I was unaware that web.config files could be used in class library
projects. I'll have to try this.

But, each of the data access libraries points to a different SQL database,
on the same database server. Also, some of these data access libraries
are used by more than one project. If I store the predominant
connectionstring in the .config file of the web application, how do I pass
that on to the data access libraries.
Thanks in advance.

--


Class library projects don't have config files themselves. When you use
System.Configuration.ConfigurationSettings.AppSett ings, it accesses the
application's configuration file (the application calling the class library
assembly). :)

Mythran

Nov 17 '05 #6
Al
This works. Thanks alot!!!

--
Regards,

Allen Anderson
"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:uj**************@TK2MSFTNGP15.phx.gbl...

"Al" <gt*****@hotmail.com> wrote in message
news:Ol*************@TK2MSFTNGP12.phx.gbl...
Greetings,

I was unaware that web.config files could be used in class library
projects. I'll have to try this.

But, each of the data access libraries points to a different SQL
database, on the same database server. Also, some of these data access
libraries are used by more than one project. If I store the predominant
connectionstring in the .config file of the web application, how do I
pass that on to the data access libraries.
Thanks in advance.

--


Class library projects don't have config files themselves. When you use
System.Configuration.ConfigurationSettings.AppSett ings, it accesses the
application's configuration file (the application calling the class
library assembly). :)

Mythran

Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Christopher Jedlicka | last post by:
I am trying to write a script that will access files on another computer on the network but in a seperate domain. In order to access the files, I need to first authenticate to the other domain as...
2
by: Yang Liu | last post by:
Hi all, I have a .net windows application xx.exe, which reference a private assembly yy.dll, the property "local copy" of the yy.dll reference is automatically set to true, so the yy.dll will be...
0
by: Pratik Mehta | last post by:
Hi Friends, I am facing trouble with dynamically compiling C# source files. Here is the example: Following command works: csc.exe /out:test.dll /target:library...
4
by: Richard | last post by:
We are distributing a VS2003 solution to our customers that includes a .NET assembly (dll file) and a sample project for how to use the dll. The customer can then customize the sample or add a new...
1
by: Steve | last post by:
I have been trying to find documentation on the behavior Can anyone tell me why the first example works and the second doesn't and where I can read about it in the language reference? Steve ...
0
by: tony | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. In this user control we have a class...
2
by: DE3A10 | last post by:
How do I change my reference Path in ASPX.NET 2.0?. I already look at http://msdn2.microsoft.com/en-us/library/6taasyc6(VS.80).aspx and I din't find reference path on the properties. Can some one...
3
by: Hugh Oxford | last post by:
I want to build a string to reference an object. I can reference is manually thus: print_r($this->struct->parts->parts); but if I build a string... $string = "->parts->parts"
5
by: colin | last post by:
Hi, I need to cache various resource objects such as images for example, wich might be referenced from multiple objects (wich could be considered documents for ease of discusion) and the idea is...
11
by: =?Utf-8?B?UGFycm90?= | last post by:
I get an error when trying to add a reference to a DLL program from a Realia COBOL program that is 32 bit. The error message says "Please make sure the file is accessible and that it is a valid...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.