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)
Related
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?
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.
I am building a desktop application where it uses a local database file (.mdf). Since I was developing it on my machine I used SQL Management 2008 R2 SP2. Then I sent it out to others for feedback. But unfortunately they were not able to use it as they didn't have SP2 installed.
So, as a resolution, I want to include a sql file that would run while installing the application. I was wondering if someone could direct me how to do so.
What I have and what I think should be done is:
- Main Project (includes forms and classes - I have this working already)
- Setup Project (includes msi file that checks database existence and runs sql file accordingly - I need help on this)
I suggest you using wix to create the msi.
You know, you can no longer create setup project using visual studio (Version 2012 above). It has been removed completely.
So you should consider going in WIX (Windows Intaller XML) direction.
If you like the idea here is the quick and easy solution:
http://www.codeproject.com/Articles/331368/WIXDataBase
http://wix.tramontana.co.hu/tutorial/sql/creating-a-database
But its completely up to you to think about the alternatives.
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.
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