Visual C#2008 Express连接到SQL Server 2008 Express问题

时间:2022-11-06 15:53:21

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.

我有连接到SQL Server 2008 Express的Visual C#2008 express(SP1)的问题。 “添加连接”窗口(无论在何处启动)都不会列出现有的sql server,除了紧凑版之外没有sql server的选项。

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.

请注意,我在同一台机器上有VWD 2008 express(SP1),它定期显示窗口(列出了SQL服务器),SQL Server Management Studio也可以正常运行。

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.

我见过其他类似的帖子,确实采取了一些建议:重新安装VC#,服务运行正常等等......但到目前为止VC#没有成功。

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)

同样,在同一台机器上,VWD定期显示带有sql server选项的对话框,但VC#在“更改数据源”对话框中仅显示3个选项(1. Microsoft Access数据库文件(OLE DB)2。Microsoft SQL Server Compact 3.5, 3. Microsoft SQL Server数据库文件)

Any idea?

4 个解决方案

#1


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

我和Phil在这个Visual Web Developer 2008 Express工具>连接到数据库...上显示了添加连接对话框,其中包含服务器名称:

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

Visual C#2008 Express具有数据库文件名(新的或现有的):

This rather implies using ado.net programatically

这意味着以编程方式使用ado.net

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

如在SqlConnection中db = new SqlConnection(); db.ConnectionString = ...

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

“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

[数据源=服务器\ SQLEXPRESS]我似乎有我的项目区域中创建的ASPNETDB.MDF文件,但不要混淆这些文件

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

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.

MVS.NET 2003需要SQL Server 2000上的Microsoft SQL Server 2000桌面引擎。这更让我想起通过ODBC使用Microsoft Access连接到SQL Server作为在Access Basic中获取“绑定控件”的方法。

#2


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

SQL 2005和SQL 2008 Express Edition将自己安装为命名实例。

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.

您应该能够输入“。\ SQLEXPRESS”进行连接。 “。”是“localhost”的快捷方式,“SQLEXPRESS”是SQL Express的实例名称。

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

您可以在“服务”控制面板中验证实例名称:

  • Start -> Run -> services.msc
  • 开始 - >运行 - > services.msc

  • Scroll down to SQL Server
  • 向下滚动到SQL Server

  • The Instance Name should be in brackets. eg: "SQL Server (SQLEXPRESS)"
  • 实例名称应在括号中。例如:“SQL Server(SQLEXPRESS)”

#3


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.

您描述了选项3 - Microsoft SQL Server数据库文件,您应该能够使用它指向.mdf文件,它将能够从此连接。

#4


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

请参阅响应中的表格:http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/51df3937-1f24-4131-80d6-486552660bad

#1


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

我和Phil在这个Visual Web Developer 2008 Express工具>连接到数据库...上显示了添加连接对话框,其中包含服务器名称:

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

Visual C#2008 Express具有数据库文件名(新的或现有的):

This rather implies using ado.net programatically

这意味着以编程方式使用ado.net

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

如在SqlConnection中db = new SqlConnection(); db.ConnectionString = ...

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

“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

[数据源=服务器\ SQLEXPRESS]我似乎有我的项目区域中创建的ASPNETDB.MDF文件,但不要混淆这些文件

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

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.

MVS.NET 2003需要SQL Server 2000上的Microsoft SQL Server 2000桌面引擎。这更让我想起通过ODBC使用Microsoft Access连接到SQL Server作为在Access Basic中获取“绑定控件”的方法。

#2


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

SQL 2005和SQL 2008 Express Edition将自己安装为命名实例。

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.

您应该能够输入“。\ SQLEXPRESS”进行连接。 “。”是“localhost”的快捷方式,“SQLEXPRESS”是SQL Express的实例名称。

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

您可以在“服务”控制面板中验证实例名称:

  • Start -> Run -> services.msc
  • 开始 - >运行 - > services.msc

  • Scroll down to SQL Server
  • 向下滚动到SQL Server

  • The Instance Name should be in brackets. eg: "SQL Server (SQLEXPRESS)"
  • 实例名称应在括号中。例如:“SQL Server(SQLEXPRESS)”

#3


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.

您描述了选项3 - Microsoft SQL Server数据库文件,您应该能够使用它指向.mdf文件,它将能够从此连接。

#4


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

请参阅响应中的表格:http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/51df3937-1f24-4131-80d6-486552660bad