简体   繁体   English

如何将Visual Studio 2010 Express C#连接到SQL Server Express

[英]How to connect Visual Studio 2010 Express C# to SQL Server Express

Is there any real workaround to getting the Express edition of C# connected to database options other than the lightweight options allowed (Access, SQL Compact, or SQL file)? 除了允许的轻量级选项(Access,SQL Compact或SQL文件)之外,是否有任何真正的解决方法可以使C#的Express版本连接到数据库选项? As has been noted elsewhere, it's possible in the web edition to do so. 正如其他地方已经指出的那样,在网络版中可以这样做。 It has also been noted that you can create a project file, open it in the web edition, create a connection, and create a project with your database entities, and then switch back to C#. 还注意到您可以创建项目文件,在Web版本中打开它,创建连接,并使用数据库实体创建项目,然后切换回C#。

However, as a workaround this is quite clunky, as it seems like if I could just get the SQL connection persisted in my C# Database Explorer, which seems to be tied to the application, not any project, then I would permanently be able to add to the database without having to constantly switch back and forth. 但是,作为一种解决方法,这是非常笨重的,因为似乎我可以在我的C#数据库资源管理器中保持SQL连接,这似乎与应用程序绑定,而不是任何项目,那么我将永久地能够添加到数据库而不必经常来回切换。

Has anyone worked through this problem? 有没有人解决过这个问题?

I figured out a better workaround. 我想出了一个更好的解决方法。 The application settings seem to be saved in [Documents and Settings]\\[User]\\Application\\Microsoft\\VCSExpress\\10.0 and VWDExpress\\10.0. 应用程序设置似乎保存在[文档和设置] \\ [用户] \\ Application \\ Microsoft \\ VCSExpress \\ 10.0和VWDExpress \\ 10.0中。 What I found is copying ServerExplorer\\DefaultView.SEView from the VWDExpress to VCSExpress after creating the connection in WD worked perfectly. 我发现在WD中创建连接完美后,将ServerExplorer \\ DefaultView.SEView从VWDExpress复制到VCSExpress。 I could from there create new objects, refresh from the data, create a database from the design, etc. 我可以从那里创建新对象,从数据刷新,从设计创建数据库等。

yes get the .net connector: http://dev.mysql.com/downloads/connector/net/ 是的.net连接器: http//dev.mysql.com/downloads/connector/net/

Use add reference to point the dll and use their functions to connect to a mysql server 使用add reference指向dll并使用它们的函数连接到mysql服务器

Ok Just to be clear about all this... I am on Windows 7 and am admin on my machine. 好的只是为了清楚这一切...我在Windows 7上,我是我的机器上的管理员。

You may have to change permissions on the following folders in the usual way. 您可能必须以通常的方式更改以下文件夹的权限。

I have visual Studio c# express edition on my machine together with Visual Web developer express. 我和Visual Web开发人员一起在我的机器上有visual Studio c#express版。 I cannot browse my local SQL server with c# express and connect to a database. 我无法使用c#express浏览本地SQL服务器并连接到数据库。 So I followed the above method. 所以我按照上面的方法。

Open an ordinary explorer window and browse to: 打开一个普通的资源管理器窗口并浏览到:

C:\\Documents and Settings\\YOURUSERNAME\\Application Data\\Microsoft\\VCSExpress\\10.0\\ServerExplorer C:\\ Documents and Settings \\ YOURUSERNAME \\ Application Data \\ Microsoft \\ VCSExpress \\ 10.0 \\ ServerExplorer

rename DefaultView.SEView to DefaultView.SEViewORIGINAL 将DefaultView.SEView重命名为DefaultView.SEViewORIGINAL

Open another explorer window and browse to: 打开另一个资源管理器窗口并浏览到:

C:\\Documents and Settings\\YOURUSERNAME\\Application Data\\Microsoft\\VWDExpress\\10.0\\ServerExplorer C:\\ Documents and Settings \\ YOURUSERNAME \\ Application Data \\ Microsoft \\ VWDExpress \\ 10.0 \\ ServerExplorer

Copy DefaultView.SEView and paste it into the folder in the other explorer window. 复制DefaultView.SEView并将其粘贴到另一个资源管理器窗口中的文件夹中。

You will now have 2 files in the folder 您现在将在该文件夹中有2个文件

DefaultView.SEView DefaultView.SEView
and
DefaultView.SEViewORIGINAL DefaultView.SEViewORIGINAL

If you open visual studio c# express 2010 you will now see your databases. 如果您打开visual studio c#express 2010,您现在将看到您的数据库。 You will not be able to create a new one to that database though. 但是,您将无法为该数据库创建新的数据库。 You will have to create any new connections in VWDExpress first and repeat the process. 您必须首先在VWDExpress中创建任何新连接并重复此过程。

Someone might want to check out how to just move the differences between these files and fix it that way. 有人可能想看看如何移动这些文件之间的差异并以这种方式修复它。

Good luck 祝好运

Yet another work around. 还有另一项工作。

Sorerons solution only works for local databases. Sorerons解决方案仅适用于本地数据库。 You will get the dreaded...'your version cannot connect ...blah blah blah'. 你会得到可怕的......'你的版本无法连接......等等等等等等。
So I opened the project in VWD...connected using Linq to sql classes. 所以我在VWD中打开了项目...使用Linq连接到sql类。 Voila,it worked. 瞧,它有效。 I had the project opened in both vde and vwde at the same time.(I was in the process of copying the project templates from my vis developer express to vis webd at the same time) 我同时在vde和vwde中打开了项目。(我正在将项目模板从我的vis开发人员快递复制到vis webd同时)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM