Click here to Skip to main content
12,824,787 members (41,311 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# SQL-Server C#4.0

I've C# app with sql server ,that I want to deploy.

-First of all, how can I add my local database to my project?
- How to deploy it ?
Posted 20-Dec-12 0:25am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You should not include SQL Server in your installation. There are a couple of reasons:
0) You can only distribute SQL Server Express for copyright reasons - not SQL Server full version.
1) They may already have SQL Server installed on the network. If so, then they will presumably want to use that version.
2) If they do have SQL server installed and you start proliferating SQL server Express instances, you are going to annoy the heck out of the database administrator...
3) A single site installation of SQl Server is a lot more likely to be backed up than a number of scattered version under user control.
4) Sql server is quite complex for a "normal" user to install and administer - it is not a good idea!
5) It will destroy the primary advantage of using Sql Server over SqlCE or SQLite - multiuser access. If everyone installs their own copy of SQL server, then you will have multiple copies of your database, each used by a single person. This will cause some confusion, and (depending on how you wrote the original database) may take some considerable effort to combine into a single instance when the problem is realized.
Member 8584763 20-Dec-12 5:38am
Ok, suppose that I did the setup to my app, then on client PC ,I should install sql server, if it's not exist? and do I need to install sql server management?
OriginalGriff 20-Dec-12 5:51am
No! If they want Sql Server, they they must install it - again it is thier choice which machine to install it, and which version to install.
SSMS is installed as part of the SQL server installation.
Member 8584763 20-Dec-12 5:55am
The app can't run without it. How come it's their choice?
OriginalGriff 20-Dec-12 6:05am
SQL server is not a trivial object - it has to be installed correctly, configured and maintained. It also has to be backed up if the customer has any sense. Unless your application is running as a single user database, the choice of which machine it should run on is very important - if you choose a machine and install it, what guarantee is there that the machine will be powered on when your customer(s) need to use it? That it will have sufficient spare capacity to run MsSql under the load of all the users? That its network connection is sufficient to support them all? If they already have a full (and expensive) copy of SQL server installed on the network, do you think they will be pleased that you install another Express version? What if two users instal your app? Should you add another version of SQL server? What happens if they both update their own copies? They can't see each others data!

And if you are running SQl server as a single user database, then your application needs some serious rethinking because there are much, much smaller footprint databases out there for single user use!
Member 8584763 20-Dec-12 6:18am
Actually, it's a single user database, and I was planning to install sql server and sql server management on the client PC. After that, I'll install my app, but the problem what if the sql server didn't run. what other database I should use? I heard of Sqlserver compact?
OriginalGriff 20-Dec-12 6:27am
SQLCE, SQLite or even Access - SQL server express has a footprint of several hundred megabytes, exposes itself all over the network, and takes valuable memory and cpu resources even when your program isn't running. It's also a PITA in that it installs all the tools the user needs to seriously bugger your database up...
(I tend to use SQLCE because most of the time it's just a case of changing SqlCommand to SqlCECommand and so forth, provided you don't use stored procedures - which are pretty much a waste of time in a single user environment anyway! It's database is also just a data file as far as the OS is concerned so it is very simple to install a preloaded "ready-to-rock" DB with the app.)
Member 8584763 20-Dec-12 6:33am
If I use SQLCE. Will it give you the same funtion as sql server management?
OriginalGriff 20-Dec-12 6:44am
Yes - SqlConnections become SqlCeConnections and so forth, but the SQL command syntax is pretty much identical, (baring the SPs and such like that CE doesn't support) - it shouldn't necessarily be a major job.
Access may be a bigger problem, the SqlConnection becomes an ODBCConnection, but the SQL functions may have different names and / or parameters in Access. The SELECT, INSERT and UPDATE syntax is pretty much identical though.
Member 8584763 20-Dec-12 6:45am
What do you recommend. Because I need to access them. to backup the database or restore it ? Which one better?
OriginalGriff 20-Dec-12 6:56am
As a single user DB, Access is pretty good - it's when you start to use it multiuser that it becomes a total PITA. SqlCE only works in single user.
It depends on what you are doing with it - but in both cases backup and restore is pretty simple, as they are just normal datafiles, stored in a normal user data area, so it's just a case of copying the file (files in the case of Access)

I generally use CE for small(ish) jobs - up to 500Mb (it defaults to 128Mb but you can override that in the connection string) but it will cope with 4GB if it has to - in theory, I've never tried that large as it is a PITA to backup a file that big every hour.
Access is limited to 2GB (2010 version), but you can link this to other 2Gb databases for a huge size if you need to.

Seriously - it depends on what you are doing with it! Both of them can be edited and created by VS or SSMS so it doesn't matter much in most cases which you chose.
Member 8584763 20-Dec-12 7:40am
SqlCE, does it have a graphic interface?
OriginalGriff 20-Dec-12 7:43am
No. But SSMS will connect directly to it and you can do the work there.
Member 8584763 20-Dec-12 7:51am
So, it'll be like sql server than but much smaller in size?
OriginalGriff 20-Dec-12 8:06am
Very similar. There are limitations (like the lack of stored procedures I mentioned) but for the most part in a single user environment they either don't matter or can easily be got round in code. See here:
OriginalGriff 20-Dec-12 8:08am
Oh and size - the footprint is a couple of MB for the .NET assemblies as opposed to a minimum of 140MB for Sql Server
Member 8584763 20-Dec-12 12:23pm
OK, but how to deploy it?
OriginalGriff 20-Dec-12 13:59pm
When you get your program working, just create a setup and deployment project for it. It will include all the necessary DLLs from your References list, and you can add the blank (or populated) database as a required data file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170308.1 | Last Updated 20 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100