Publish C# project with database - c#

I'm currently learning C# with Visual Studio 2013 and planning to write an application with Database. There i have some questions:
What's the best database to publish with my application to
friends/customers? The database won't be too big. And every user
should use his own database.
How do i publish my application with the database and make an installer from it? I want to give customers a setup.exe that they can install. With everything they need, i.e. .net, database, etc
Thanks in advance

Here is a good SQL Comparison Table that shows what you can and can't have with different options (SQL Server Express, Local DB, SQL Server Compact / CE).
You probably want SQL CE so you can bundle up an actual database file with your installer.
As for the installer, you'll need to create a Bootstrapper which will contain your installer + other installers you require + your database that you're releasing (assuming you mean a pre-populated database?).

MS SQL Server Compact edition would be a good choice. It's free and redistributable with Your application. No extra installation needed. http://www.microsoft.com/de-de/download/details.aspx?id=17876

For really small databases, you could use sqlite.
Otherwise, I'd suggest using MS SQL Server, it has a free Express edition. I don't think attaching another install.exe would cause problems.

Related

What do the end users of my program need in order to use it?

I created a c# program which relies solely on .NET and SQL Server. What do the end-users need to install in order to use my program? I know they have to install .NET Framework but I'm unsure if the program will work without the appropriate SQL files. or am I wrong?
I'm sorry if this question is rather misguided but this is my first program.
If your application is using SQL Server you will need to install SQL Server AND the database your application is looking for.
.NET Framework does not include SQL Server but SQL Server will install the .NET Framework. (SQL Server 2016 installation)
SQL Server 2016 Express had a LocalDB version that may suit your needs. LocalDB is a lightweight version of Express that has all its programmability features yet runs in user mode and has a fast, zero-configuration installation.
Good luck with your first program. :-)

Use sdf database(SQL Server Compact 3.5 database file) without installing Microsoft sql server C#

I want to use a database in my C# program but I don't want other users who want to use my program to have to install a big volume software like Microsoft SQL Server that is more than 2 GB. So, can I use .sdf database (SQL Server Compact 3.5) without Microsoft SQL Server?
When I give my published software to anyone with a normal Windows 7 OS (that most probably does not have Microsoft sql server installed) he should be able to use my software without any requirements. My program is really simple, but involves saving data in a database.
I don't want users to be forced to install Microsoft SQL server !
SQLite may also be an option;
http://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki
Used it on a project recently and works really well.
Try the site below, I've found it useful in the past. The subjects referenced there are still valid under Visual Studio 2008 / SQL Server Compact Edition 3.5.
http://arcanecode.com/2008/08/12/getting-started-with-sql-server-compact-edition-35/

Placing a database within WinForm project and licensing options

We plan on pushing a windows application on computers external from our companies network (in various locations). I'm wondering what options I have for databases. I'd like to use SQL Server, but is there a way to avoid paying for licenses for each PC we load the windows application on?
Also, is there a way to have the data part of the executable when deploying the application, or would I need to install SQL Server on each machine?
Thanks!
As an alternative and a bit newer technology to Sql Server Compact Edition, you could use LocalDB.
Both are MS SQL products, but LocalDB doesn't have the disadvantages of CE, is still a file based DB and doesn't require the server installation, configuration and maintenance of SqlServer Express, only the runtime components.
Here you can find a nice comparison between Express, Compact and LocalDB
and here you can find the introduction of LocalDB by Microsoft.
The licensing of LocalDB is the same as for SqlExpress and you also need an installer to run for the runtime components of LocalDB (which is one downside when compared to CE).
Is there a way to avoid paying for licenses for each PC we load the windows application on?
Presumably you're just accessing a local database on these machines right? In that case you can use SQL Server Compact. It's free and pretty darn good.
Is there a way to have the data part of the executable when deploying the application?
If you're deploying your application via ClickOnce, then you can set SQL Server Compact as a prerequisite so the application will check for its presence and install it if needed.
Otherwise, you can push it out like any other prerequisite as part of the installer package (i.e. InstallShield or WiX).

How can I release a program with a database?

I just finished writing a large program that uses a pretty large database file. In the past, when I finished writing programs, I just uploaded the .exe file to my website and sent the link to whoever wanted to use it, but now there's also a database file to include..
Is there a way to "wrap" the database file in the .exe? If not, how can I release my program so that the user only has to download one file? I've never created an installer, nor do I really know how.. I've only ever just uploaded .exe files :).
Any help would be appreciated. Excuse my inexperience :P.
The program is programmed in C#, and the database file is in .mdf format (I am running SQL Server 2008). I'd be happy to provide any more details. :)
Instead of bundling the entire database, you should make the application know how to create the database. A simple way is to create a script for the entire database in SQL Server Management Studio. Then include the script (probably after you've made some adjustments to it) in the exe file as a resource file.
A better approach than rolling your own solution is to use a data access framework such as EF Code First with Migrations that has database creation and upgrade support built oin.
You can make simple setups from visual studio (Create new setup project). If you need more advanced features, have a look at Windows Xml installer
You can include the free Sql Server Express so your users don't have to buy a license of SQL server. If you want to go through the effort of building an .msi installer, I believe you can do SQL-server - specific actions.
On the other hand, if you have a small amount of data, you might consider using the filtering features of Dataset instead of relying on SQL server.
Edit: Microsoft has a new SqlServer 2012 LocalDB that might be interesting:
New to the SQL ServerĀ® Express family, LocalDB is a lightweight
version of Express that has the same programmability features, yet
runs in user mode and has a fast, zero-configuration installation and
short list of pre-requisites. Use this if you need a simple way to
create and work with databases from code. It can be bundled with
Visual Studio, other Database Development tools or embedded with an
application that needs local databases.
(excerpt from here)

Database included in an application

i have a winform application in c#on visual studio, connected to a database in sql server 2008 and i have done a deployment to it so to use it i must install the sql server management studio and restore the database backup, so Can i when doing the deployment and setup project include or take the database backup to not need to install the SQL server management studio on the PC use this application and from the application i will take a backup from the updated database which has new records
So how do i make a deployment and setup project and embedded in it the database used so i'll not be needed to install the sql server in the PC which act as a server and the clients PCs as i want to use the application in a network?
If your database is trivial, should be accessible from a single computer and is used to store local data look to the.
http://www.microsoft.com/sqlserver/2008/en/us/compact.aspx. For sure you will need to read additional articles about how to use it and deploy it, but this should be a starting point. NOTE: you will not have stored procedures and advanced SQL Server features, but you will use the same code as you do now.
Note that if you want to restored a database from backup to an arbitrary SQL Server instance, you may encounter problems if the instance to which the backup is being restored is configured with options different than the original SQL Server instance (e.g., collation sequence, case-sensitivity, ANSI settings, etc.) If the default collation sequence is different, you may have problems with indices, for instance.
You can use sqlcmd for that, it installs with MSSQL server on client machine look here for details.
After you created bat file, you can run it from code use Process.Start
It's not the SQL Management Studio that is needed to be installed to make the program work, it's SQLServer that must be installed.
For small applications it maybe to much of work to administrate a SQLServer, in that case its better to use other database types... I used to use XML files, lately I use Sqlite, its very good no installation required. and it integrates great into Visual Studio.
Edit: If you only need to restore a .bak you could use that http://sqlbackupandftp.com/restore/ its very nice and easy, and its a very small file.

Categories

Resources