C# Windows Application Deployment - c#

I developed a windows application using C# that has a database. The database is attached to my local SQL Server Management Studio. Now, I want to deploy my application (C# + database) so that it can be simply installed on other computers using an installer (setup file). I'm so new in this field. Please guide me that what steps I should follow to do this. Thank you.

Follow these,
1) First get some idea on how to create MSI within Installer Class Read
2) Create a command prompt app which should have the logic to create a Database in local SQL server. Check my post here
3) Pack the command prompt exe with the MSI package.
4) Within the insatller class's Install() method write logic to execute the command prompt exe.

There are few things to consider before going for deployment.
Do you have a centralized application? Meaning do you want to host your database on server or you want to deploy on each users machine.If you want it to be centralized then how are you going to access the database. Does your current structure supports it? like are you using SOA to access db or anything else?
If you have decided that you want to deploy your database along with your application on your client machine then you will have to deploy your database along with your setup. You can read a tutorial here on how to achieve this.

Related

Where to store an Access DB in a VB.Net App?

I am beginner of c# in vb.net. My question is where should I keep access databse to making database application. Because when I distribute it what I need to make global connection string that available client pc. client install in any drive so what I should do to complete the vb.net database application. please advice me step by step because I am beginner
Thanks in Advance
Manish
First thing first,
If your client has not installed Access, you will either have to force him to install or distribute your system installer with embedded Microsoft Access Database Engine Redistributable which you can find on this link.
Microsoft Access Database Engine Redistributable usually provides you everything that you need for Access database usage for .NET
You can always put your file in application directory. As GeirGrusom mentioned, it is not a good practice though. You can get the file path as shown in this link.

SharpDevelop C# Windows Application is ready to deploy .. how to move sql database to client pc? what else i need?

I just done with programming client's application by SharpDevelop C# .. Now i need to install the software to customer ... What i need exactly to do?
I know some steps .. but i'm not sure if something is missing ..
1)Build Project to .exe
2)Move built project to client pc.
3)Move database to client pc. <<<<<<<<<<<<<<< I'm using MSSQL sqlexpress .. How to move the database to client pc?
4)change connection string in configuration file to suit the new changes.
5)installing the following in client pc:
SQL Server Management Studio
Net Framework
so my question is in number (5) how to move database ...
my 2nd question is anything missing that i have to do?
Thanks in advance..
I think your steps are qualified for many Winform Apps, so you can do it as your steps, then to test it on a new machine. if it works well, then you can do the same things on your clients' PCs.
in other kinds of apps, there may be other things to do, such as set environment variables, add register keys, and so on. but I think they are unnecessary to do them, so you just test as your steps.
about you asked how to move database, I usually copy the mdf file and ldf file together to clients' PCs, then attach them into SQLServer Management Studio.
good luck!

Windows service install doesn't have correct privileges

I have a service that I have created for Windows. The service works fine. The problem I am having is a permission issue. My service accesses a .mdf SQL Server database file that is created when the service is installed (using Installshield VS 2012).
The service itself is running as user. When I install I input my credentials and I can successfully start the service. The service starts fine. However, when I get to the part in my code where I have to open the .mdf I get an error because the database log file does not exists and the service does not have permissions to create it.
The only way I can fix it is by adding my username or authenticated users for example to the security section of my program files folder. This allows the SQL Server .log file to be created and my service continues running.
What is the best solution to getting around this? Basically I want to be able to run the service and local system and it have the privileges to install and create the .mdf.
Thank you for the help.
You should create the database log file during the installation. You can run custom code during the installation to do that (the code may be similar to what triggers creation of the log file in your regular code). That will use the user with elevated permissions so it will work well and is correct from the security point of view (all administrative tasks should be done during the installation in this case).
It's better not to add permissions for a normal user to SQL Server data folder as that will lower security.

How to deploy a Windows forms project with a database connection to some other machine?

I have a small demo windows forms application, which has 2 forms.
enter a name in the first form, which will add the name to a table in the database. The back-end used is SQL Server 2008.
After successful entry in the database, the user is prompted to the second form, which is basically a demo calculator.
My question is how can I deploy this project to some other machine. Wana create a normal executable file, in the other machine.
I was able to deploy one another windows forms app, which was without a SQL database connection, by using the Setup and Deployment wizard of the VS 2008.
Also, does the other machine would have to have certain prerequisites, like presence of SQL server in it?
I googled... found some MSDN links but could not find meaningful results.
Any assistance or an external pointer to this scenario would be highly appreciated.
You can get connections string using ConfigurationManager and set connection string in app.config.
Getting connection string from app.config example:
string connStr = ConfigurationManager.ConnectionStrings["myConnStr"].ConnectionString;
After deploy you application you can change app.config manually or make in your app simple form for set connection string.
You could try adding a Setup Project to your Solution and relay on the automatic dependency detection that it brings to build an MSI setup kit for your application that would bundle any dependencies. Not sure about the SQL Server though...
Since it needs a DB for its execution, you have to provide a sql server instance for it. This can be any of these below mentioned
a dedicated SQL server on the network
SQLServer installed on any one of the machines on the network and configured correctly for accepting connections from other machines on the network
SQL Server local instance installed on the second machine if the second machine is not on the network or the program is independent of the network.
AFAIK, for deployment you can copy exe (built after proper connectionstring configuration) or you can rely on setup project

Deploy Windows Application with SQL database "security part"

i would like to Deploy my windows application written with c# (Express edition 2010) and SQL server express edition 2008 and i want to know how to do the following:
The steps to deploy the Application and how to set all settings(i think with express edition there is only one way click once method, but how set the settings for it?
after Deploy my application what i have to do to setup or install it in the customer machine(requirements for software side) to make it work?
What is the best location to place my database files(MDF and LOg) in the customer machine c: or D: and how to prevent any one to access the database without using Application because the connection string is like that:
"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\FamilyHistory.mdf;Integrated Security=True;User Instance=True"
Finally i want to know how to make backup for the database from time to time , is there any automatic method to do that or i have to make manualy by copy it form the customer machine.
You can have a look at a number of deployment methods. You can use click once but i strongly advise using something like NSIS(open source). You can use a software HM NIS Edit(also free) that does the hard work for a .net project. Try it on your own machine and then you will know how to deploy. By client i take it you mean your customer rather than client/server type client?
the answer to three i believe (although i rarely do the old file sharing nowadays) that you should place the file in the temp folder in windows, however, i am willing to be wrong about that.
It depends on what data provider you are using however, you simply create a sqlcommand object(as i'm sure you know how) then enter in the backup sql something like:
BACKUP DATABASE AdventureWorks2008R2
TO DISK = 'Z:\SQLServerBackups\AdvWorksData.bak'
WITH FORMAT;
GO
i hope that has helped.

Categories