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.
Related
I was wondering what would happen to a program's connection to the database after compiling it to setup.exe? Will the data from the server explorer be saved somewhere after producing a setup installer so it could dynamically be changed later?
I'm still a bit new in coding. Just barely started.
So I'm not really sure if my questions would make any sense to all the experts.
I hope someone could enlighten me.
Thank you.
It all depends on what form of Database and what settings you had in your project.
case 1:
you are using a server-client Database. Server-client databases are like Sql-Server, MySql, Postgresql, Oracle.....
Usually they have a host, username, password and/or authentication method.
In this case, and while you are configuring your database with in your project in visual studio, you can choose to save the connection string with in your configuration file resources or hard code it in the application.
The Data will stay on the database server.
Case 2:
You are using one of file Database solutions like Sqlite, VistaDB, Acess DB file, XML based DB files, Sql-Compact SQL-CE (obsolete and replaced with SqlExpress)...etc.
In this case, the DB file (which should be in your project file and you have chosen from visual studio the option of (copy if newer)) will be included with your project with the data in it. You have to be sure in this case the proper assemblies are present with you your application *.dll. Your installer have nothing much to do here unless the DB solution you have chosen said other wise.
For example, if you used SqlExpress your installer should be sure that it is present when your user installs your application and if not it either installs it or instruct the user (at least by providing proper links) the methods to install it.
As for the connection string it takes the same conditions of case 1.
Hence you tagged your question with #sql-server I will assume you are looking for the SqlExpress case.
If that's the case I will refer you to the couple of links which will provide you with further details:
1- How do I connect to an MDF database file?
2-How do I connect to an .mdf (Microsoft SQL Server Database File) in a simple web project?
3-C# - Connect to MDF database
4-THE ‘CONNECTION STRING’ STRING OF CONNECTION WITH DATABASE. AN EXAMPLE OF USING IN APPLICATIONS
Finally remember web search is always your friend:
5-c# sql server connection string attach database file (in google search)
How can I ran x86 .net 3.5 Windows Forms app with .mdf database on the computer without SQL Server (for example, XP of common user).
I have found few samples of connection strings, but all of them are contains something like Data Source=.\SQLEXPRESS
Doubt, that user will be having SQLEXPRESS on his computer. I want something like work with Access db - so user could work without even knowing, what's server, only with local file
MSSQL I have chosen instead of Access, because in the future I can add publish DB on server, but not now.
Maybe, I should use SQLLite, but how in that case?
Thanks.
How can I ran x86 .net 3.5 Windows Forms app with .mdf database on the computer without SQL Server?
This question has very simple answer - you can't!
You must distribute and install some version/edition of SQL Server with your application, otherwise the .mdf file will be nothing more than waste of disk space. You can install SQL Server along with your app. For more information you can see Install SQL Server from the Command Prompt and Install SQL Server using a configuration file. If this is a simple app working locally on a single workstation, you may want to consider using SQL Server Express LocalDB.
Another option is to use different database engine, which has easier deployment and embedding - SQLite, Firebird Embedded, etc. Pick one that you like. Most of these solutions require only to distribute one DLL/assembly with your application. You will not get the full power of SQL Server, but for most apps, it isn't needed anyway.
I'm using Visual Studio 2015 and I just created a Windows Forms application with a SQL Server database. I finished the program and tried to run the application on the other computer but it didn't run. I also tried to install .Net Framework v4.0 and SQL Server Express on that computer and also put the database in path C:\ so that the SqlConnection path on my computer to another computer will be the same.
The code is like this:
SqlConnection cn;
SqlCommand cm;
SqlDataReader dr;
string connection = #"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Database1.mdf;Integrated Security=True";
But I got an error that is the database I placed in path C:\ is not writable whatsoever. I want to know what I can do in order to run the application.
You must install SQL Express on the computer/server where you want to have the database and then attach the MDF file.
Important:
- Remember to open port 1433 in the Windows Firewall.
- If you are going to use SQL Server authentication, you must create and / or activate the user with the desired password.
- To connect you can use the IP of the computer/server, preceded by the instance of sql express. Example: YourIP\SQLExpress
Good luck!
you need to create sharing server for database and after this, you can access your DB to anywhere and any computer
Thanks
So much misunderstanding and misinformation around LocalDB.
While it was being developed, your application was using an edition of SQL Server called LocalDB. This is a low admin lightweight edition that lets you reference the MDF file directly (contrary to some comments here)
When you deploy your app you decide whether you want to stick with LocalDB or upgrade to a more scaleable edition of SQL Server.
In your case, I suggest you stick with LocalDB
There's some background here and a link to a video if you have time
LocalDB deployment on client PC
https://blogs.msdn.microsoft.com/sqlexpress/2011/07/12/introducing-localdb-an-improved-sql-express/
Now if you really want to an answer you need to post the exact error message that you see, not a vague recollection of it.
The problem might be that LocaDB is not installed, or it might be that there is some SQL Server access issue. We can't tell because you did not post the error message
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!
I have a nice program idea, it will be a very simple application that will save your username and password on a sql server database file, i know how to do it, but the problem is i don't want the client to install sql server in order to add or remove a record in database, besides i want my database file embedded into the application so the user have a single .exe file, i heard about a library called sqllite or something, it`s function is not to let the user install sqlserver to make the application work.
You can use SQLCE and search for SQLCE private deployment, basically it is a light weight of MS SQL on client side. With privatedeployment you just need to copy related DLLs to your project folder without installation.
You are looking for SQL Server Compact edition.
You need to use a file based SQL database.
There are several - most popular are:
SQLite
SQL Server CE
See this SO question - Free portable database.
As you mention, Sqlite is an option. It's a compact and file based database. No need for installing anything. The full database resides in a file. You'll need to reference the Sqlite database engine for connecting to it, however.
I probably wouldn't use SQL at all if you are only going to create one table with a few (< 100) rows. Its way to much overhead for that small amount of information.
I would save the username and password in a file, then use the Enterprise Libraries Cryptography Application Block to secure the file.
You also most likely don't want the storage engine embedded into the exe, then your passwords are tied to that specific application on that specific computer. You will have to implement an import/export program anyway to move your info to another machine.
Check out http://keepass.info/
Yes , you can implement it by
SQLite ,
SQL Server CE ,
Or Xml
And also , in my last project , the application call the webservice when need to access DataBase.
So , there are lots of ways to avoid install SQL Server on client PC .