I have a WPF application that I want to deploy to client PCs via a Setup. My setup application will contain the .Net framework and SQL Server Express 2008 edition and will install these on the client if needed and without user interaction.
Now I need a way to create the database and tables, etc... on the client without any user interaction.
Should I deploy the .MDF .LDF to the client PCs and attach the database to SQL Server Express?
Or should I create a script and run the script on the client to create the database and tables?
Plus, I need to ensure that the app.config settings are correct.
What is the best way to handle distributing a database to the client during a Setup.exe with user interaction?
If you're deploying a stand-alone application to desktop clients, forcing them to install SQL Server Express is the wrong choice. You're going to run into issues if SQL Server stops working on the client's PC.
You should instead use SQL Server Compact Edition (which doesn't require a server to be installed on the client's PC). You can include the database file as part of the installation process with all of the blank tables and everything already created.
Related
We are developing a small application that needs to have a local database installed on each users computer that will then sync up to the main database, via web services etc...
Anyways when we deploy the application on the users computer we want to use clickonce deployment. Now I have used this before but not attaching a SQL Server database. I know you can go to prerequisites in clickonce properties and click SQL Server Express.
Now the question is, when you have created your .mdf database file including stored procedures and all - how do you get this attached and setup automatically in the local database that is just installed through clickonce?
Also once this is finished in the future we may want to run updates to the database on the clients machines. We would like to use clickonce for this to publish database updates. Obviously we don't want to overwrite the database and just publish the latest updates based on if they already have the database or not and what version they have.
How could this be achieved using clickonce? Thanks
I am about to begin a personal project to build my skills in the .net environment. I am familiar with SQL Server Management Studio and how to create a database in it but I discovered how to make a local database in Visual Studio as well. My program is only going to require local database access as it will be used for individual inventory systems rather than connected ones. Am I ok to use the onboard tools in visual studio and create a local databasse or should I be using the SQL Server Management Studio?
When you use the Local Database item template in VS, it creates a SQL Server CE data file (SDF) and adds it to your project. When you use the Service-based Database item templete, it creates a SQL Server (Express) data file (MDF) and adds it to your project.
The advantage of using the VS tools is that the data file becomes part of your project and can therefore be easily deployed with the compiled application. As such, the database is basically part of the application.
If you choose SQL Server CE then you don't need a server installed on the user's local machine. They can install SQL Server CE or you can install it with your app if you want, but you also have the option of simply deploying a DLL with your app and it will work.
If you choose SQL Server Express then the user actually needs a SQL Server instance installed on their machine. To be honest, I'm not 100% sure whether that instance must be SQL Server Express or it can be a full SQL Server instance too. It would usually be SQL Server Express though, which you can install and even download automatically when you install your app, depending on the deployment method you choose.
If you use the VS tools to create an MDF data file then your connection string will contain the Data Source and AttachDbFilename attributes. The Data Source will generally be ".\SQLExpress", i.e. an instance named "SQLExpress" on the local machine. That instance name is not required, although it is the default for SQL Server Express, but it must be on the local machine. The MDF file gets attached at run time and detached again when you're app is done with it. It will also usually be attached to a user instance, which means that other users can't see it, even when it's attached. Note that, in later versions, the LocalDB feature of SQL Server may also be utilised.
If you create your database in Management Studio then it's not actually part of your app. It will be permanently attached to the SQL Server instance so, everyone will be able to see it and open it, assuming permissions allow. Creating the database during deployment will be an extra step in that case. You might create a backup and restore that during deployment or generate SQL scripts that get run. In this case, your connection string will contain the Initial Catalog attribute to specify the name of database to connect to, as well as the Data Source attribute. This option is required if you want multiple clients to be able to connect to the database.
In short, if you are only going to be accessing a database from the local instance of the one application then creating a database in VS is OK and probably a good idea. Whether you choose SQL Server CE or SQL Server Express may well depend on what level of functionality you need.
I have developed a application in c# which is windows based application. It stores data into database sql server. I want to know, when I create setup in VS and install it in a client computer should I install sql server software also or Is there any way without installing SQL Server in client's PC My application can function correctly.
sIf you use a filebased implementaion of SQL (localDB) you should be able to get away with a "setup" installing the neccecary dependencies to bootstrap the DB. (Someone correct me?)
If you use the DB in a hosted SQL environment (SQL Server running as a service), you will need to install SQL server on the deployed pc, and get the database up.
I am no sure if you can "automate" installing SQL server and getting the DB up from a setup app.
You have two deployment options for applications that contain SQL Server Compact 3.5 databases. The method of deployment you choose depends on the servicing requirements of your application and whether your users will need administrative credentials on the computer on which the application will be installed.
Following are the deployment options for SQL Server Compact 3.5 databases:
1. Traditional Microsoft Windows Installer (Microsoft setup technology)
a. Users need administrative credentials to install the application.
b. SQL Server Compact 3.5 will be serviced by Microsoft Update.
c. Can use ClickOnce deployment.
-or-
Private file–based deployment (deploying the SQL Server Compact 3.5 DLLs as part of the project)
1. Users do not need administrative credentials to install the application.
2. SQL Server Compact 3.5 will not be serviced by Microsoft Update.
3. Can also use ClickOnce deployment.
I want to deploy an MVC 4 web application to a Windows Web Server 2008 based dedicated hosting. I am using SQL Server 2008 R2 Express as my back-end database. What steps will I need to take regarding the following:
Installing SQL Server 2008 R2 Express on the web server and deploying my database.
Managing SQL Express database remotely using SSMS.
Configuring database path in my EF5 generated model
Deploying my application
Managing changes to my application.
Can someone provide me a detailed answer/some good links?
Installing SQL Server 2008 R2 Express on the web server and deploying my database.
This depends on your provider. Most providers, if not all, allow you to install your own licensed SQL Server. If you will be using an Express edition then it is, and should be, 100% allowable by your provider. The only step you need here is to go to download page of SQL Server 2008 R2 and download the appropriate file you need. The files you need on that page are the ones with "ADV" in its name. Choose x64 if you will install a 64-bit OS or choose x86 if you will install a 32-bit OS.
Managing SQL Express database remotely using SSMS.
This depends on the firewall set by your provider. But basically this is how you will allow remote access to your SQL Server:
For Windows 2008 R2
Login to your dedicated server using Remote Desktop. If you don't know how to do this, it's best that you consult with your provider.
Go to Start > All Programs > Microsoft SQL Server 2008 R2 > Configuration Tools -> SQL Server Configuration Manager
On the window that open in step #2, expand SQL Server Configuration Manager (Local) -> SQL Server Network Configuration -> Protocols for SQLExpress
On the right pane, right-click TCP/IP and select Properties.
Select the IP Addresses tab and then scroll to the IP All section.
Set/change the TCP Port value to/from 1433 to 14333 (or any other port) and then click OK.
Right-click TCP/IP again and Enable it
Restart your SQL Server by going to Start -> All Programs -> Administrative Tools -> Services -> SQL Server (SQLEXPRESS) -> Restart. The Restart is on the left pane.
Configuring database path in my EF5 generated model
Unfortunately, I cannot answer this one as I believe you are using the EF designer in creating your model. I never worked with EF that way, but only by code-first. I have to skip this part and let you Google this.
Deploying my application
There is already a good documentation written here so I will not dupliate it here. Basically what you need to do is enable FTP on your dedicated server. Then once that is setup you can go on with bin-deploying your application.
Managing changes to my application.
I assume what you are asking here is that if you have changes to your application, how would you re-deploy it. A bin-deployment will not hurt. Deploying only the files in which you have changes is a good approach. Knowing which files changed can vary depending on the tools you use. In addition, if you don't have any fancy setup that will tell your users you are deploying changes to your site, you might want to take a look at this post. It tells you to put a App_Offline.htm file in your root web directory. That should still work with MVC, after all MVC is still ASP.Net.
I am a bit confused after reading around the internet that this cannot be done.
I have an application that I install on clients machine. This application uses SQL Server 2008 database that is installed along with the application. The database contains some tables that contain important information like giftvoucher balance.
I want to prevent unauthorised access to the database but problem is since I am installing my database on client machine they already have access to the SQL management studio through windows authentication.
Is it possible to prevent them from getting access to my database and tables ?
Your options:
DBDefence (not free)
Transparent Data Encryption
Switch to Sql Server Compact Edition