Why we use Web.Config File for connection string wether we can use class Library for get connection for whole web Application

 Why we use Web.Config File for connection string wether we can use class Library for get connection for whole web Application



please help me?

9/15/2008 5:32:21 PM
asp.net.futures 1064 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 1

Friend, Web.config has its own advantages.

1) Web.Config is used to store the important information like connections strings etc...so that it can be modified even after the code has been
    deployed to the server without compiling the entire application again.

2) Since it is a XML file, there is no need of building the project of you are going to change the connection strings.


If you go for the class files, they belong to the part of the compiled dll and hence there will be no opputunity to modify again the connection strings once you have deployed.

They have the compiled all the times if you have modified the code in the class files.


Hope this has cleared u r doubts. Good luck!

Please Don't forget to click "Mark as Answer" on the post that helped you.
This can be beneficial to other community members reading the thread.
9/15/2008 6:27:26 PM


for example, you deployed your application and suddenly those people from infrastructure decide to alter the connection string you need to use. A web.config's quickly changed but in the case of the class library you need to alter it, build it again, deploy it to the server.

Grz, Kris.

Read my blog. Handy Firefox plugins for web developers.

Workaround for non working Mark as answer buttons.
9/15/2008 6:28:12 PM

Similar Artilces:

OLEDB Connection problem using Connect String from Web.config
Hi,Cananybody tell me why I am getting the following error for the following code below An OLE DB Provider was not specified in the ConnectionString.  An example would be, 'Provider=SQLOLEDB;'. "Ppp" is a connection defined in Web.config which works with SqlDatasource in the application. DataSet RunQuery(String QueryString) { String ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Ppp"].ConnectionString; OleDbConnection DBConnection = new OleDbConnection( ConnectionString); OleDbDataAdapter DBAdapter; DataSet ResultsDataSet = new DataSet(); M....

Web App connecting to database using web.config file
I am using the web.config file to store my database connection string. Everything was working fine when I was running to applicaiton on my local machine. However, when I deployed to the web I keep on getting this error: System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open() at Dev_verI.Basi...

How to use DSN in connection string in web config file?
Hi I need to use a DSN in web config file but I dont know how to use it. My Web Hosting company limite the database file( access) must be placed in a specified folder (DATA). and use DSN to establish the connection. The DSN files is: africaDSB.dsn [ODBC] DriverId=25 ReadOnly=0 FIL=MS Access DBQ=\data\africa Thanks Hi hotjava, Try this for file DSN: FILEDSN=c:\myData.dsn;Uid=myUsername;Pwd=;NOTE:If you find my response contains a reference to a third party World Wide Web site, I am providing this information as a convenience to you.Microsoft does not control these sites and...

Using web.config Connection strings in Code Behind Files
in asp usually i have code behind files those .aspx.vb file.can i make use of connection strings in there? i am not really familiar with connection strings. actually shouldn't code behind files "simulate" code being in the .aspx file themselves? i seem to not able to share variables between them?  They can be accessed via System.ConfigurationManager.ConnectionStrings["YourConnectionStringName"].ConnectionString. If I remember right, you should surround the access to these with an "if (!DesignMode)", because for some reason they won't be loaded by...

how to store the connection string in the web.config file and use it from frontend?
I have a requirement like i have to store the connection string in the webconfig file instead of using again on each aspx page.How can i do it? hi    Check this  Web.config <?xml version="1.0" encoding="utf-8" ?> <!-- Web.Config Configuration File --> <configuration>   <appSettings>     <add key="ConnectionString"       value="server=localhost;database=Northwind;uid=sa;password=secret;" />   </appSettings> &nbs...

How can i use connection string from web.config in Crystal reports?
Hi!i am using asp.net 2005,sqlserver 2005 and crystal reports for .net 2005.i connected the crystal report file(Customer.rpt) to the database using OLEDB(using Database Expert).But i need to connect it using connection string from web.config file.I've used the following connection string in web.config file<connectionStrings>                <add name="OrderEntryConnectionString" connectionString="Data Source=(local);Database=OrderEntry;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/></connectionStrings...

How do I use my web.config connection string in my DataAdapter/Connection that I created with drag/drop and data binding
This is a little hard to put into words... I have a form with a number of textbox fields on it that are bound to a data adapter. The data adapter and it's sql connection were created by dragging the objects onto the screen from the toolbox (not in code). I open connections in other places and use my connection string in web.config for those. The on-screen sql connection object doesn't seem to allow me to just fill in the function that pulls my conn string from web.config so in page.load, I set it's connection string to my connection string. Does the page load fire before the connect...

How to save connection string in "web.config" and use in application ??
Hi;Can anybody plz tell me that how can i save my connection string in "Web.config" file. And then How can i access this string in my application globally(throughout the application). Freelance Web Developer & HTML IntegratorASP.NET(1.1/2.0) == PHP try this :http://www.google.com/search?hl=en&q=web.config%2Bconnectionstring <appSettings>            <add key="mydbvariable" value="server=myserver;uid=myusername;pwd=mypassword;Trusted_Connection=no;database=mydb" /></appSettings> the a...

I have a connection string defined in the web.config file and as you know it is given a name.How can I reference such a connection string from a web form using the name given in the web.config file?What I actually do is to copy and paste the whole string in my web forms as follows:Dim pgConn As New PgSqlConnection("User Id=postgres;Password=p@ssw0rd;Host=localhost;Database=e-restdelivery;Persist Security Info=True;Schema=restaurant;Protocol=2")This method is not efficient because if the string changes I have to modify every web form where a connection string is locat...

Using a connection string from web.config
Ok. I thought this was going to be easy but it is turring out to be harder than I expected. I want to use a database connection string from the web.config file. If I use a sqldataadapter and configure a connection then the page works fine. If i attempt to use the information from the web.config file I get the following message when attempting to connect to the DB. The ConnectionString property has not been initialized. Here is the code that I am using to establish the connection. Imports System.Web.Security Imports System.Data.SqlClient Public Class WebForm1 ...

How to use Connection String from Web Config
Hi All, How do I use the Web Config connection string in code behind? What is the syntax Dim oCnn As New SqlConnection= ???? Thanks    Dim oCnn As New SqlConnectionoCnn.ConnectionString = ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionStringDont forget to import System.Configuration Regards Mike [MVP - ASP/ASP.NET]My site...

Initialising and using a database connection using web.config
Hi All,I'm getting quite confused.Up until now I have used VS.NET to create my database connection for each page which I have created in my web app.However, I really need to store the connection string in one place (i.e. web.config) to make any changes alot easier.Can somebody give me an example of how to initialise this connection string and open the database connection using C#, then run a very simple SQL statement with 1 parameter, just so I can see the syntax.I have tried a few different ways but no luck as yet.Thanks in advance. In the web.config file, create a new tag <appSettings...

Get connection string from web.config and secure that connection
Hi, I store my connection string on my web.config file, and I want to create a new connection on c# like:SqlConnection con = new SqlConnection();con.ConnectionString= //connection string on web.config fileAfter that, The connection string on the web.config file is in clear text and I want to make it secure but easy to work because this job is to deliver until friday. Is there any easy way to do this and keep the possibility of creating a new connection and making reference to this connection string without need for decrypt data?Thanks, please help!Best regards,David Ribeiro After reading t...

How to use 2 web.config file in a single web application
Hello Guyz,In my web application I'm trying to use a Blog and for that I'm using the free version of community server. The blog itself runs fine. But I'm trying to use it as a subdomain of my original application.The blog itself has its own web.config file as my application does and for that it's throws the following  errorParser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS. It'...