How to connect Visual Studio 2010 Express C# to SQL Server Express

强颜欢笑 提交于 2019-12-10 16:17:46

问题


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)? 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#.

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.

Has anyone worked through this problem?


回答1:


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. What I found is copying ServerExplorer\DefaultView.SEView from the VWDExpress to VCSExpress after creating the connection in WD worked perfectly. I could from there create new objects, refresh from the data, create a database from the design, etc.




回答2:


yes get the .net connector: http://dev.mysql.com/downloads/connector/net/

Use add reference to point the dll and use their functions to connect to a mysql server




回答3:


Ok Just to be clear about all this... I am on Windows 7 and am admin on my machine.

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. I cannot browse my local SQL server with c# express and connect to a database. 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

rename DefaultView.SEView to DefaultView.SEViewORIGINAL

Open another explorer window and browse to:

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.

You will now have 2 files in the folder

DefaultView.SEView
and
DefaultView.SEViewORIGINAL

If you open visual studio c# express 2010 you will now see your databases. 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.

Someone might want to check out how to just move the differences between these files and fix it that way.

Good luck




回答4:


Yet another work around.

Sorerons solution only works for local databases. 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. 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)



来源:https://stackoverflow.com/questions/9847688/how-to-connect-visual-studio-2010-express-c-sharp-to-sql-server-express

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!