Does Visual Studio Server Explorer support custom database providers? - c#

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

Related

Create setup file from C# project with SQL server database in Visual Studio 2015

I want to create a setup file from a C# project in Visual Studio 2015 that attaches a SQL server database, and I want to run that setup file on another system and run without Visual Studio and SQL server
You are have two solutions
You should develop your application with SQL express on .NET framework or after develop with SQL Server change connection string from SQL Server to SQL express and rebuild it, be sure you create initialize DbContext class to set some data for run your application at first time with base and default data. [Such as application users and rolls and groups].
You should develop your application with dependency injection pattern [Microsoft Unity, IoC] then modify or replace one interface to change your developed application database.
Then Right click on project in solution explorer and publish it and give to customer.
The customer server has to run some kind of SQL Server if you want the SQL data to be accessed somehow. One thing you can do is to deploy your C# project with Visual Studio, export all needed tables (including their data if you want that) from whatever server you are using (for example MySQL) into a .sql file and pack everything, including instructions on how to install the sql server and your application, into a zip file and ship it to your customer.
What I do with my website application is, that I include a .bat that fetches everything from my git repository, deploys my web application on an existing IIS-Server on the current computer (with 'aspnet_compiler -f -c -u -errorstack -v /web -p "source directory" -d "target directory"' and 'iisreset /noforce') and automatically imports the SQL tables to an existing MySQL Server (with mysql --host=localhost --user=user --password=password --database=database < Backup.sql).
Sorry for that general answer, but you're question really wasn't that precise.
If you want to create a setup of your project then,
Click on Build on the top of visual studio tab and then click on Publish "yourprojectname" click on it and your setup file will be ready.
Hope this helps you
Use LocalDB,
(no need to at least open sql server management studio)
When you create Setup file add prerequisite
.net framework version
sql server (2012 -2019) express localdb
Add connection string correctly!
So from what I can gather you are looking for an easy way to distribute your database schema to clients, is that correct? If so then I don't see how you could intend to run the setup without SQL Server (without VS is fine though).
Assuming my assumption is the case then I think you need to think about a solution that will handle schema upgrades as your project develops, in which case it's essential that you move to Database Projects in Visual Studio as it will handle upgrading the schema automatically, and allow you to run change scripts for the things it can't do automatically (like when you've changed a column type or removed a column etc).
Here are some links to get you started:
Working with Database Projects (MSDN)
Introducting Database Projects for Visual Studio (youtube)
Using the knowledge that CSPROJ files are just MSBUILD scripts at the end of the day you can now publish the database project during whatever your installation/upgrade system is using msbuild which is included in the .NET framework i.e. you don't need Visual Studio.
This is by far the most robust and reliable way of dealing with database deployment. I would advise staying well clear of automated tools like Redgate, they do a great job for small projects that maybe get used in an office etc but for professional software development you need more guarantees and control.
You can try this, with Octopus deploy.
Or, you can try with Code First migration
Have you already existing database, or development starts now?

Visual Studio 2013 Server Explorer custom data provider: MongoDB

Is there any way to add MongoDB as a custom data provider in Visual Studio 2013 Ultimate?
Server Explorer / Connect to Database
I have installed the latest MongoDB C# driver.
There are two APIs to be found on the network, both of them implements the ODBC standard:
One NYU Master's Degree (summer) project, which is compatible with the C++ driver;
Another, which is provided by Simba Technologies and available for a trial run.
After downloading and installing the connector, one must perform a setup with the provided administrator tool, as shown in the following picture.
After testing the connection in the ODBC Data Source Administrator, one should head over to the Visual Studio's interface, where the Database Connection setup is. One must choose the .NET Framework Data Provider for ODBC as a data provider, and the Simba connector will be available, as the following picture shows:
That's all!
Another ODBC driver was recently released that can be used here. It has a unique feature in that it exposes the nested MongoDB data model as a set of relational tables. As a result, the interaction with "relationally" minded apps like Visual Studio will be drastically improved:
http://www.progress.com/products/datadirect-connect/odbc-drivers/data-sources/mongodb
You should add the references to the MongoDB driver to your project.
You can do this by right clicking on your project in the solution explorer.
And then click Add Reference. Then you can locate the dlls from the MongoDB Driver.
After that you can use them in code.
Source:
http://msdn.microsoft.com/en-us/library/wkze6zky.aspx
http://www.drdobbs.com/database/mongodb-with-c/240151668?pgno=2

How do I change the Data source into Microsoft SQL Server in Visual C#?

I was using this tutorial and I'm stuck in this part. The guide tells me to choose 'Microsoft SQL Server', however this is not included in the options of my computer. I only have 'Microsoft Database File', 'Microsoft Server Compact', and 'Microsoft Database Server File'.
How could I add the option 'Microsoft SQL Server'?
I don't think the express version can natively connect to SQL server. I can't seem to find any documentation on this, but if I recall correctly it was one of the reasons we switched to pro way back when. Anyways, perhaps this post will help: How to connect Visual Studio 2010 Express C# to SQL Server Express
If yours is a web application, then you can do it the way its shown in your tutorial,
but if yours is a Winforms of WPF application you can't do it with Visual Studio Express..
There are other ways to connect using SqlConnection, SqlCommand objects etc, which are not design time..you can use them however..
maybe you are missing some component try to download http://www.microsoft.com/web/downloads/platform.aspx
please select option other from that part and then select ".NET Framework Data Provider for SQL Server" from that list. please try let me know

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)

Visual Studio Express can't change data source

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.

Categories