views:

303

answers:

3

I'm new to ASP.NET and to SQL Server. I'm from the PHP/MySQL world, so I'm pretty confused with this stuff. I need help because I'm trying to make a simple blog as a first serious exercise. I can't figure out how to connect to my sql server from my c# code. my sql server is on the same machine as IIS. When i use SQL Server Management Studio, it says its connecting to BAMF\SQLEXPRESS. Is that what i should put in my connection string? A little guidance would be great.

+2  A: 

Yes, that would work on your machine. To make it more portable, you might want to use .\SQLExpress in which the dot means the local machine (whatever computer name it has) and SQLExpress is the instance name of the SQL Express installation.

Mehrdad Afshari
+4  A: 

http://www.connectionstrings.com/

Standard Security Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;Use serverName\instanceName as Data Source to connect to a specific SQL Server instance.

Are you using SQL Server 2008 Express? Don't miss the server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server Express installation resides.

schooner
A: 

In this case, BAMF is the name of the server/computer SQL Server is running on. SQLExpress is the named instance of the database. There are tons of ways to set up your connection string, just google and you'll get your answer.

Chris Conway