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.
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.
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 = ConfigurationManager.ConnectionStrings; string conStr = ""; if (settings != null) { foreach(ConnectionStringSettings setting in settings) { if (setting.Name == CONNECTION_NAME) { conStr = setting.ConnectionString; } } return conStr; } else { 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?
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.
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.
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?
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.
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.
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.
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?
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.
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:
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:
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?
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.
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 < add name="QkINDUSConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|QkINDUS.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
know what is the correction i need to make in ConnectionString ?
I have this in the web config file <connectionstrings> section. Why is there an add and then remove and then again an add...what is it trying to accomplish here? and in the second code section, I use that string in a sqldatasource control. Second question: Can I just use the name attribute value "localsqlserver" form web config file, in place of the connection string in the data source? is it why that attribute is for?
This may be more of a general ASP.NET question although I'm not sure. My project is MVC 1.0 so I thought I'd post here. I've searched but found nothing specifically applicable.
I'm using the default membership/authentication functionality as provided by the MVC template. The requirement is that I allow the user to set the connection properties individually in the <appSettings> section of Web.config rather than as a single value in the <connectionStrings> section. I can easily enough retrieve the data and turn it into a connection string, but I can see no way to make use of it in code.
I would like to use both of the connection strings in the same web.config file how can I do this I tried this yesterday it worked I called it a night, then this morning I got this. The error being on line: 10 Parser Error Message: The entry 'ApplicationServices' has already been added.
Line 8: <add name="ApplicationServices" Line 9: connectionString="Data Source=Mysource;Initial Catalog=travelatlantic;User ID=MyID; Password=MyPassword;" /> Line 10: <add name="ApplicationServices" Line 11: connectionString="Data Source=MySource;Initial Catalog=travelatlantic2;User ID=Myid; Password=MyPassword;" /> Line 12: </connectionStrings>