VS 2008 - Configuration Files - Fetch The Connection String From The Data Project?

Nov 3, 2010

I ahve a solution with a few dll projects, a winforms testbed and a WCF webservice project. In the data project, I have a base class that does the following:

public class BaseDAO
private const string CONNECTION_NAME = "OracleConnectionString";
protected static string GetConnectionString()
ConnectionStringSettingsCollection settings =
string conStr = "";
if (settings != null)
foreach(ConnectionStringSettings setting in settings)
if (setting.Name == CONNECTION_NAME)
conStr = setting.ConnectionString;
return conStr;
throw new NotImplementedException("The connction string can't be found");

You might ask, why do I need to loop and check the name against a constant? Well, I have defined the connection string in the service project's web.config, but this above code always find two connection strings, one is a sqlexpress which I guess is a default database of some sort. So, to separate that one against the one I really use, I have to loop through all entries and pick out the one I plan to use. How do I prevent this? Is there a better way to fetch the connection string from the data project?

View 3 Replies

Similar Messages:

Configuration :: Connection String For SQL 2008 R2 Aspnet Db?

Sep 1, 2010

give me an example of the proper connection string for getting VS 2010 to use the aspnet database on my SQL 2008 server? The db is there, I just can't seem to get connected. Server name GUNSITESQL, mixed security. I want to logon with a SQL user logon id, the db name is the default aspnet.

Currently, the web.config file is the default.

View 2 Replies

Configuration :: SQL Server 2008 - Can't Get Connection String Right After Many Attempts

Mar 8, 2011

I have a new server that I am attempting to deply my very first asp.net website on. I have installed SQL 2008 r2 and loaded my DB on it. I am able to access the server/DB through Visual Stuidio. At least I know i can call it from the webserver to my local PC.

For some reason I just cant get my we.config's connection strong right. It might even be the <provider> info that I have wrong. I am just too inexperienced to know for sure. My Web.Config is very short so I will post all of it here.

-- Code is posted at the end --

How do I modify my local project to use my webservers DB instead of the standard SQL Express DB? The only connection string

Machine.Config that points to the sqlexpress database. Again I lack the experience to know how to do this. I am using Visual Studio 2010 and SQL Server 2008 r2 on my local pc.


View 3 Replies

Configuration :: Encrypting The Connection String In Web.config On Windows Server 2008

Mar 30, 2010

When I try to encrypt the "connectionStrings" section in the web.config file of my asp.net web application on Windows Server 2008, I'm getting the following error:

Administration utility (2.0.50727) to install and uninstall ASP.NET on the local machine. Copyright (c) Microsoft Corporation. All rights reserved. Note: This utility has limited capabilities on the Windows Vista operating system. It is recommended that you use the "Turn on or off Windows features" option of the "Programs" component of Control Panel to install or remove ASP.NET. It is also recommended that you use the IIS Manager component or the Appcmd.exe tool to configure ASP.NET applications.

The above information is followed by the list of valid options to aspnet_regiis.exe.

The command that I've used is:

aspnet_regiis.exe -pef "connectionStrings" "C:Usersuser1DocumentsMywebsite" -prov "DataProtectionConfigurationProvider"

But, the same command is working fine when used on a Windows Server 2003 machine. The problem is occurring only on Windows Server 2008 with IIS7.

View 1 Replies

Configuration :: Give Password In Connection String For Ms Access Database In Configuration File?

May 2, 2010

I have an ms access db file and now i want to use it in my app. i have given like

Provider=MSDASQL.1;Password=pwd123;Persist Security Info=True;User ID=swgp;Data Source=SWGP;Initial Catalog=C:swgp BJswgp

but it is giving error to me.If anybody know how to give this connection string for password enabled ms access database,

View 2 Replies

ADO.NET :: Use Connection String And Strongly Typed Dataset Which Exists In Another Project ?

Sep 22, 2010

i have a winform application with huge strongly-typed dataSet. Now, i've decided to create a web edition of my application and i want to use strongly-typed typed dataSet which exists in my winform application. also it's tableAdapters create with the connection string settings which stored in my winforms app.config. My problem is that how to use strongly-typed dataset of my winform app with new connection string which exists in my web app?

View 2 Replies

VS 2008 OleDb Connection String In Web.Config

Aug 14, 2010

How to put an OleDB Connection String in Web.Config I wrote the following code but getting error

<add key="ConnectionString"
value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("~/App_Data/AMS.MDB")" />

Getting error while concatenating a string Data Source=" & Server.MapPath

View 4 Replies

SQL Server :: Connection String To Connect With 2008?

Sep 23, 2010

be it's a wrong place to ask the following question. Sorry for that. Our hosting provider has recently upgraded their database server from Sql Server 2005 to 2008 and I'm getting errors to connect with remote server from my development machine. Error Message "Invalid connection". Tried to find solution on net but couldn't find it.I'm using .Net 1.1. Though we've updated versions 2.0,3.5 & 4.0 but due to some certain circumstances I've no way to update it. It's a web based project. The following connection string works fine for Sql Server 2000 & 2005 but not for 2008.<add key="ConnectionString" value="Data Source=Remote Server's domain name;Initial Catalog=database name;User ID=user name;Password=surround;Persist Security Info=True;Pooling=false;Connect Timeout=45;" />Here Remote Server's domain name indicates to remote db server like: test.mysite4now.comdatabase name for example: test_surrounduser name like test_surroundpassword: surround.Can anyone inform me what's wrong with the above connection string to connect to Sql Server 2008.

View 9 Replies

Configuration :: How Does IIS 7 Gets The Connection String

Jun 17, 2010

I have created a ASP.NET 4 application in VS 2010 using Silverlight and RIA Services.

After finishing the first release on my development pc, I'm starting some deployment testing in a server in my local network.

After sucessfully published the web application using the Visual Studio FTP publishing option, I notice two strange things:

1 - On the IIS properties of the website I have uploaded my files to, you can see now a connection string, named as LocalSqlServer that points to the aspnetdb.mdf database file. I had a look in the web.config file and I could not find this connection strind defined there. So, where is it located? Where did IIs got it from?

2 - As the aspnetdb.mdf file is not deployed withtin the web application and I a musing SQL express in my testing server, where can I drop the mdf and ldf files so they can be attached when the applicaiton runs? I know I can perform an attach operation using management studio,but I'm wandering where is the DataDirectory folder ASP.NET looks for to attach it at runtime?

View 4 Replies

DataSource Controls :: Common Connection String In LINq To SQL Files?

Feb 20, 2010

I am using LINQ to SQL files in my class libray since every LINQ to SQL sources file is a seprate file and i have to set database connection string in each class library. Now, i have total 7 class libraires in my project how connection string be passed from web.onfg to LINQ file, so that i don't need to manually change the connection string. lke we did in asp.net 2.0 using connection string property in class file library.

How could we pass the same in LINQ's designer file.

View 4 Replies

VS 2008 Can Use A Session Variable In A Web Config Connection String

Jun 16, 2010

Can you use a session variable in a web config connection string? So instead of:


<add name="ConnectionString2" connectionString="Data Source=ora;Persist Security Info=True;User ID=SA;Password=PASS;Unicode=True"

something like this:


<add name="ConnectionString2" connectionString="Data Source=" & Session(DB) & ";Persist Security Info=True;User ID=SPAR;Password=;Unicode=True"

View 6 Replies

SQL Server Express 2008 Using (local) In Connection String

May 18, 2010

Is it possible to connect to a SQL Server Express 2008 database in ASP.NET with a server name of (local) like "server=(local);integrated security=SSPI;database=DBNAME"? I'm working with another developer on a project and it's getting annoying having to have 2 different version of web.config because he is using SQL Server 2008 and (local) works, but I can't seem to get it to work with SQL Server 2008 Express locally. The database is located on the same computer as the .NET code in case that matters.

View 2 Replies

SQL Server :: Connection String For Sql 2008 Express R2 And Publishing?

Sep 17, 2010

I am currently working on a project and I am hosting it on my IIS to test it every so often but now i have an issue:

When i run in debug mode with this connection string:

Data Source=.;AttachDbFilename=c:New folderdbname.mdf;Database=dbname;Trusted_Connection=Yes;

everything works fine and i can access the database but once its published onto my iis it doesnt find the database?

View 5 Replies

Configuration :: Connection String Visible In IIS?

Dec 9, 2010

I have decrypted my connection string in web.config file of the application programatically. But after deployment under the ASP.net tab of application virtual directory when I click edit configuration the connection strings in web.config file are visible in decrypted format i.e readable form.

View 3 Replies

Configuration :: Is Possible To Have More Then One Connection String In The Web.config

Oct 19, 2010

I have been preparing for a conversion of an old application to an ASP.NET webapplication at beginning of the year. Generally, the development version of the webapp will also be the webapp that goes into production. We here make "clones" of the database server, assign new name, etc, which is then used for development, training, and so on without any threat of changing data on the real db (sql server 2005). I know it is possible to have more then one connection string in the web.config. My question centers around if there is a simple method for allow multiple connection strings and pick the one that is to be used for dev, production, training, and so on? I originally thought about constructing some type of admin form that the connection string can be selected from.

View 2 Replies

Configuration :: Get Sql Connection String From Web.config?

Dec 15, 2010

I have an app that is a bit old and will eventiall be rewritten but until I get the time it needs to continue to be patched. THe app is desgined broken into three layers (Web, DAL, BLL) The web site uses the DAL.DLL and BLL.DLL and the Website has some dataaccess and the sonnection string is saved in the web.config. For the DAL it is stored in the app.settings. Is there a way for the DAL to use the connection string that is stored in the Web.config even thought it is in DLL for the production site?

View 2 Replies

Configuration :: Connection String Encryption?

Nov 3, 2010

I was reading about how it is a good idea to encrypt the connection strings for security purposes. I came up with a solution that I think may be somewhat elegant, but there may be big flaws in my thinking. I am overworked and tired :)

Basically I have a setting in the web config EncryptConnectionString. In the Global.asax. Application_Start I am checking this in the config. If it is true, I am encrypting the connection strings. If it is false, I am decrypting the connection string.

Question #1 Is there a better way?

View 1 Replies

Configuration :: Cannot Get The Connection String Correct?

Aug 15, 2010

I finished my first asp mvc project and want to post it to a iis7/sql2008 server.I published the site just fine and migrated the sqlexpress database to sql2008 with no problems.However, when I run the program it still connects tp sqlexpress and opens a user instance.For the life of me I cannot get the connection string correct:

The current sring is:

<add name="AlertEntities" connectionString="metadata=res://*/Models.Alert.csdl|res://*/Models.Alert.ssdl|res://*/Models.Alert.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Alert.mdf;Integrated
Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />

How do I change this to make it see the sql2008 database?

View 6 Replies

VS 2008 - Call Connection String From Webconfig File From Web Form?

Nov 18, 2010

How do I call the connection string in the webconfig file from a web form?

View 4 Replies

Configuration :: Files Needed To Deploy Project?

Nov 29, 2010

what files are needed to deply a project?

View 1 Replies

Configuration :: Exclude Files From Web Setup Project?

Aug 4, 2010

I try to create a web setup project. Following this example ttp://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx everything was perfect. Now I need to find how going trought the wizard exclude some files from Content files Output.

View 3 Replies

How To Change Configuration Tool Connection String

Jan 10, 2011

how can I change ASP.NET Configuration tool-s connection string name? (Which connection string will ASP.NET Configuration tool will use)

I'm learning ASP.NET and everywhere and in book that I'm reading now theres connection string named: LocalSqlServer.

I want to use my local sql server database instead of sql express to store Roles, Membership and other data.

I have used aspnet_regsql.exe to create needed data structures in my database. after that I changed my web.config to look like:


View 1 Replies

Configuration :: Multiple SQL Instance In Connection String?

Dec 9, 2010

I have 3 Databases that I am pulling data from for my web site. 2 of the databases are in the same SQL instance, however the 3rd one is in a different SQL instance. Both of the SQL instances are installed on the same server, one of them is a Named instance and the other is installed under the default instance. So my connection strings look something like this:

<add name="ABCConnectionString" connectionString="Data Source=BobDataDB;Initial Catalog=Bob;User ID=*******;Password=*********;" ProviderName="System.Data.SqlClient"/>
<add name="BCDConnectionString" connectionString="Data Source=BobDataDB;Initial Catalog=Sue;User ID=*******;Password=*********;" ProviderName="System.Data.SqlClient"/>
<add name="EFGConnectionString" connectionString="Data Source=Bob;Initial Catalog=Sue;User ID=*******;Password=*********;" ProviderName="System.Data.SqlClient"/>

I'm in the process of moving this application from the Development Server to the Production Server when I noticed this issue. Previously the ABC and BCD connectionStrings where pointing to a different server and instance. So my question is how do I get this wo work with the server names being the same but the instances being different?

View 4 Replies

Configuration :: Variables In SqlDataSource Connection String?

Aug 13, 2010

Some databases that my application has to access have their name according to the current year because the ERP we work with creates a new database every year, so, now it's working with the 2010db database. There are two options (as far as I know) for the ConnectionString property of a SqlDataSource: 1) hard-code it or 2) pick it up from the web.config file.

I don't want to change manually the connection string every year, so, how can I solve this? I would need to take the value of Now.Year either in the hard-coded ConnectionString or for the Web.Config ConnectionString, but I don't know how to do that.

View 3 Replies

Configuration :: SQL Express Connection String On Hosting?

Dec 20, 2010

I have created a web site in Visual Web Developer 2008 Express Edition. I have created database using SQL Server Express. The web site works good. I have hosted the web site, then getting error in connecting to database.

The connection string is
Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|QkINDUS.mdf;Integrated Security=True;User Instance=True"

know what is the correction i need to make in ConnectionString ?

View 3 Replies

Copyrights 2005-15 www.BigResource.com, All rights reserved