Visual Studio Express can't change data source - c#

I am trying to add a SQL Server data source to a C# console app.
When I try and add a new connection to my .dbml file the only Data Source available is Microsoft SQL Server Database File (sqlclient) whereas I need Microsoft SQL Server (sqlclient).
The change button is grayed out, so I can't change it.
How do I change this?
(I wondered if it was a bug, so tried uninstalling/reinstalling Visual Studio - but still no joy.)

This is actually a limitation of the Express product and you can get around it with a modification of your SQL Server connection string manually. For more information have a look at this SO Post.

I got this working by using the workaround from the post above:
Workaround:
1.Open your solution in Visual Web Developer Express. It will not load some of the projects in the solution but it is ok.
2.Make a new connection in Database Explorer to the required database from SQL Server.
3.Add a new class library project.
4.Add a LINQ to SQL Classes item and link it to your database.
5.Close the solution.
6.Open the solution in Visual C# Express.
Now you have a LINQ to SQL classes library that is linked to your SQL
Server database in Visual C# Express.

Related

Cannot add new Local Database in Visual Studio 2013

I am going through a tutorial that is adding a simple local database to a C# console application but when adding a new item to the solution I cannot find the Local Database to insert a .sdf database file. I have tried to download SQL Server Compact 4.0 but upon installation it says that SQL Server Compact 4.0 is already installed on the computer. Below is a screenshot of the available data resources I can add.
How would I be able to add a local database file to my solution?
You should use the ADO.NET Entity Data Model and use Entity Framework to generate models from your database. You can select your local database there.
Eventually found this question that has already been answered that solved my problem
How to connect to LocalDB in Visual Studio Server Explorer?

Use VS2013 to browse localdb

I am trying to follow along with this article (EF Code First) and whilst the code runs and the output is what I expect, I can't browse to my LocalDb from within VS2013. I see my SQL Server 2012 developer instance but not my LocalDb. I can't find my .mdf file either.
The post says I should see the database in SQL Server Object Explorer, but I can't, and it doesn't seem obvious how to add it. I know I have SQL Server 2012 installed, and some of my project require it, but to get the most from the article I'd like to be able to follow along exactly.
Any ideas how I can see my project database file from VS2013?
Jason.

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

Unable to connect to Sql Server Express database

I installed Sql Server Express 2008 R2, and created a database file in Sql Server management Studio. Now From Visual Studio 2008 I try to connect, but it fails with error:
Unable to open the physical file
"C:.....mdf". Operating system error
32: "32(The process cannot access the
file because it is being used by
another process.)". An attempt to
attach an auto-named database for file
C:....mdf failed. A database with the
same name exists, or specified file
cannot be opened, or it is located on
UNC share.
...This is first time I use Express. I only used Sql Compact Edition before. Are there some settings here I need to figure out? It's not a duplicate name of other connection, and I have closed management studio completely. Still this error. What am I missing..?
If there are some settings, please give a little detail how I access them, as I'm not used to dealing with databases.
SQL CE is a file based database - SQL Express isn't.
It is a SQL Server - you can add it using the Server Explorer in Visual Studio.
The instance name is normally .\SqlExpress.
I faced the same issue today, and guess what daemon tools was the reason for this problem, so if you have installed daemon tools uninstall it and then try again.
Hope it solves your problem too.
You do not want to be connecting using the mdf. What you want to do is Open a SqlClient.SqlConnection and then using the SqlClient.SqlCommand execute queries on the database, and then read the information using the SqlClient.DataReader, just like you would with A SqlCE database.
If you are trying to add it to the Server Explorer you just need to connect to the database just like you would in SSMS (Management Studio) and then you can use it in your project.
If you created a database in SQL Server, you probably have it attached. In Visual Studio you cannot access this database as a file. You have to access it as an attached database (i.e. by its name).
Generally you can use database in files as well in Express edition. If you for some reason want to use file directly, then go to Management studio, right click on your database and detach it. Then you can connect to it from Visual Studio on file basis.

Does Visual Studio Server Explorer support custom database providers?

I had used Server Explorer and related tools for graphical database development with Microsoft SQL Server in some of my learning projects - and it was a great experience. However, in my work I deal with Oracle DB and SQLite and my hobby projects use MySQL (because they are hosted on Linux).
Is there a way to leverage the database-related tools in Visual Studio with other database providers?
Here is instructions on how to connect to your MySQL database from Visual Studio:
To make the connection in server
explorer you need to do the following:
first of all you need to install the MyODBC connector 3.51 (or latest) on
the development machine (NB. you can
find this at
http://www.mysql.com/products/connector/odbc/
)
Create a datasource in Control Panel/Administrative Tools with a
connection to your database. This data
source is going to be used purely for
Server Manager and you dont need to
worry about creating the same data
source on your clients PC when you
have made your VS.NET application
(Unless you want to) - I dont want to
cover this in this answer, too long.
For the purpose of this explanation I
will pretend that you created a MyODBC
data source called 'AADSN' to database
'noddy' on mysqlserver 'SERVER01' and
have a root password of 'fred'. The
server can be either the Computer Name
(found in Control
Panel/System/Computer Name), or
alternatively it can be the IP
Address. NB. Make sure that you test
this connection before continuing with
this explanation.
open your VS.NET project
go to server explorer
right-click on 'Data Connections'
select 'Add Connection'
In DataLink Properties, go to the provider tab and select "Microsoft OLE
DB Provider For ODBC drivers"
Click Next
If you previously created an ODBC data source then you could just select
that. The disadvantage of this is that
when you install your project
application on the client machine, the
same data source needs to be there. I
prefer to use a connection string.
This should look something like:
DSN=AADSN;DESC=MySQL ODBC 3.51 Driver
DSN;DATABASE=noddy;SERVER=SERVER01;UID=root;PASSWORD=fred;PORT=3306;SOCKET=;OPTION=11;STMT=;
If you omit the password from the
connection string then you must make
sure that the datasource you created
(AADSN) contains a password. I am not
going to describe what these mean, you
can look in the documentation for
myodbc for that, just ensure that you
get a "Connection Succeeded" message
when you test the datasource.
I found this during my research on Sqlite. I haven't had the chance to use it though. Let us know if this works for you.
http://sqlite.phxsoftware.com/
System.Data.SQLite System.Data.SQLite is the original
SQLite database engine and a complete
ADO.NET 2.0 provider all rolled into a
single mixed mode assembly.
...
Visual Studio 2005/2008 Design-Time
Support
You can add a SQLite connection to the
Server Explorer, create queries with
the query designer, drag-and-drop
tables onto a Typed DataSet and more!
SQLite's designer works on full
editions of Visual Studio 2005/2008,
including VS2005 Express Editions.
NEW You can create/edit views, tables, indexes, foreign keys,
constraints and triggers interactively
within the Visual Studio Server
Explorer!
The Server Explorer should support any database system that provides an ODBC driver. In the case of Oracle there is a built in driver with Visual Studio.
In the Add Connection Dialog click the change button on the data source you should then get a list of the providers you have drivers for.
Oracle has a set of tools that integrates with Visual Studio. It's packaged with their data access libraries.
http://www.oracle.com/technology/software/tech/windows/odpnet/index.html

Categories