3

I have a problem with Visual C# 2008 express (SP1) connecting to SQL Server 2008 express. The "Add Connection" window (wherever initiated) doesn't list existing sql server and no option for sql server except a compact edition.

Note that, I've got the VWD 2008 express (SP1) on the same machine which shows the window regularly (with SQL server listed) and SQL Server Management studio works fine with the server as well.

I've seen other similar posts, did take some advices: reinstalled the VC#, services run ok, etc... but with no success with VC# so far.

Again, on the same machine the VWD shows the dialog with sql server option regularly, but VC# shows only 3 options in "Change data source" dialog (1. Microsoft Access Database File (OLE DB) 2. Microsoft SQL Server Compact 3.5, 3. Microsoft SQL Server Database File)

Any idea?

Linger
  • 14,942
  • 23
  • 52
  • 79

4 Answers4

2

I am with Phil on this Visual Web Developer 2008 Express Tools>Connect to Database... brings up Add Connection dialog with Server name:

Visual C# 2008 Express has Database file name (new or existing):

This rather implies using ado.net programatically

as in SqlConnection db = new SqlConnection(); db.ConnectionString= ...

"Data Source=.\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=True; providerName=System.Data.SqlClient";

[Data Source=server\SQLEXPRESS] I seem to have ASPNETDB.MDF files that have been created in my project areas but do not confuse these with

C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\master.mdf

MVS.NET 2003 required Microsoft SQL Server 2000 Desktop Engine ontop of SQL Server 2000. It all rather reminds me of using Microsoft Access to Attach to SQL Server via ODBC as a means of getting 'bound controls' in Access Basic.

Rat1960
  • 31
  • 3
1

SQL 2005 and SQL 2008 Express Editions install themselves as Named Instances.

You should be able to enter ".\SQLEXPRESS" to connect.
The "." is a shortcut for "localhost", and the "SQLEXPRESS" is the Instance Name for SQL Express.

You can verify the instance name in your Services control panel:

  • Start -> Run -> services.msc
  • Scroll down to SQL Server
  • The Instance Name should be in brackets. eg: "SQL Server (SQLEXPRESS)"
  • Will, thanks for the quick response, unfortunately, everything is fine with the server (I checked it out earlier), but looks like something's wrong with the VC#. I also tried to use many variations in Advanced window settings, including .\SQLEXPRESS, MYHOSTNAME\SQLEXPRESS... :( –  May 22 '09 at 12:59
  • Ah, in that case -- have you checked that you can connect using the sqlcmd tools too? eg: C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd -S .\SQLEXPRESS –  May 22 '09 at 13:33
0

Could it be that the express product won't let you connect in the normal way because it qualifies as 'remote'?

See the table in the response: http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/51df3937-1f24-4131-80d6-486552660bad

justin w
  • 603
  • 1
  • 6
  • 6
0

You described option 3 - Microsoft SQL Server Database File, you should be able to use this to point to your .mdf file and it will be able to connect just from this.

Peter C
  • 2,257
  • 2
  • 25
  • 28
  • Hi Cookey, thanks for the response I'm able to point to .mdf file, but I would like (for some reason) to use connection to the server the same way as I do with VWD, if possible. –  May 22 '09 at 13:12