how to C# project public with .mdf file - c#

How can I publish a C# project with a .mdf database? I would like that it can be setup easily and need not install a sqlserver. Do I need to change to .sdf?
The Project only uses it in local.

.MDF files are SqlServer main data files, i doubt you can use them without SqlServer installed, as for SqlServer Compact Databases (.sdf) they can be used like you want but converting from one to another isnt just a matter of changing the extension, they are db with different formats.
You would need to create a new .sdf and replicate the schema you have in your .mdf and then copy your data somehow, also you would need to adapt your project since access to data on an .sdf is different than an .mdf not to mention .sdf doesn't support all the things that .mdf does

Why don't you simply deploy your application with .mdf file along with a SQL Local DB installation on user machine who doesn't havd Visual Studio installed?
Make sure you install proper LocalDB. i.e. x86 version of installer on 32 bit and x64 installer for 64 bit machine. There is two different installer for both achitechture.

Sql Server is not installed as part of Windows installation, so you cannot use an *.mdf file in your app unless Sql Server has been installed and you have appropriate permissions for it.
It is possible to distribute either Sql Server Express Edition or Sql Server Compact Edition (recommended) with your app.

MDF files are part of SQL server databases. Without SQL Server (or Express), you can't use them.
If you need an embedable database, SQLite is a good option. Firefox also ships with an embedded SQLite instance, so it's a good/proven option. SQLite also integrates well with ADO.NET; I wrote an article on that here.

Related

Install SQL Server compact database .Exe file automatcally when I install WPF application

I had developed a WPF application, and its backend is a SQL Server CE .SDF file. In setup and deployment project I added .SDF file in it
The issue is: to access and get records from the .SDF file we require an additional software. Please find the below Link
https://www.microsoft.com/en-in/download/details.aspx?id=17876
It has 2 exe files
64 Bit
86/32 Bit
Visual Studio directly installs this software when we install VS
On a client system, I didn't find these files so I am unable to access the .SDF file and get records from it
I need to Copy these files in Application folder and Automatically Install it if the above software is not Present in the PC
Now I am Manually Installing these software(exe ) in Each PC
You're mistaken - to deploy a SQL Server CE 4.0 based application, you do NOT need to deploy and/or install any additional software to your client system - it suffices to include the necessary, relevant SQL Server CE 4.0 DLL's into your application (into the bin or lib folder or something), and just ship those files with your application. That's all you need - no server-side or client-side install needed ! (That's the WHOLE POINT of using SQL Server CE, after all!)
See these links for in-depth descriptions of how to do it:
Right here on Stackoverflow:
How to deploy SQL Server Compact 4.0
Another way to do it:
How to deploy the SQL Server Compact Edition software locally
Official MSDN documentation:
How to deploy a SQL Server Compact 4.0 database with an application

Publish C# project with database

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.

What's the Concept of local database of sql server in .net

Let's suppose I made an application in .net using sql server as database.
So if I want to deploy my application to some another PC i have to instal sql server
but I want that i should not install the sql server and my database should be automatically installed
i just want to make sure that is the concept of Local Database can fulfill my requirement
if so then how is it possible for me
thanks
You can use App_Data folder in the visual studio to store your .mdf files.Once you transfer your solution to a different system , the db file will be transferred automatically.
http://msdn.microsoft.com/en-us/library/ex526337.aspx
You should run your SQL server on a separate computer (server) to avoid having to install SQL server on all client computers. This way all PCs running your application can share a single instance of SQL Server.
If you want a single user DB per application instance I would recommend using SQL Compact edition instead
You can use SQL2012 Express Edition LocalDB. This uses a self contained file for your database, and can be installed as a prerequisite. When your application installs, you can install a blank database file, and connect to it.
SQL Server is not a small application that will be installed automatically and will require setup and configuration. You can however use it remotely. Or consider using an embedded database. But if you want to use a local database, you can use your mdf file of the database as a local database.

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.

Does a mdf implies the application's database is not embedded?

I have installed an application and each file saved is .mdf. During installation of the software I have not seen any database being installed, and after installation I checked my program files and not SQL server or other database server being installed. I though the application would have an embedded database, but SQL Compact should only generate .sdf file, not .mdf file - what kind of embedded database sever would create .mdf file?
There's a fair chance that Sql Server Express User Instances are being used. Though if you're sure that you've checked both Program Files and Program Files(x86) and can't see any references to Sql Server then that can't be the case. That said, use the Services management console (Start > Services.msc) and look for services whose names start with "SQL Server" to verify that for definite.
One thing worth bearing in mind is that just because an application saves files with an extension of .mdf that doesn't mean that the files are Sql Server files. I could save a text file in notepad as myfile.mdf, but that still wouldn't make it a Sql Server file.
All of the other editions of SQL use .mdf files. See here: http://msdn.microsoft.com/en-us/library/ms233817.aspx
Another way to check if some SQL database is running is checking your Services management console. even SQL express should have a service.

Categories

Resources