.Net Application Installation 2012 with database - c#

I have built a Windows Forms application using Visual Studio 2012 and MSSQL 2008. I need to deploy this project using InstallShield Limited Edition.
While running this application on my pc, it does nto work well when I use the following connection string or .//SQLEXPRESS.
I need the installer to find the exe file of the application on other uer's pc with the database file. Where do I need to put my database files in the deployment files folder? What should my connection string be?

i use .//SQLEXPRESS it doesnt work as well
DO NOT use .//SQLEXPRESS as datasource name in the connection string.
Recommended way is to menthion Instance Name if your application is to be deployed in different environments(especially OS). I ran into trouble when I had the Datasource as .dot which worked in Win 7 not in WinXP. Either one of the following approach works fine.
(local)\SqlInstanceName
(ComputerName)\SqlInstanceName Ex: CD-SJHONES\SQLINSTNACE
In certain cases i had to include the computer name, So during the application deployment i get the computer name and update the connection string accordingly.
where i need to put my database files in deployment files and folder
and what should be my connection string
Connection string
I have already answered connection string releated question above.
Database files
What do you mean by database file. how database is created in the client machine ? do you create a database during application deployment or users manually create it with script ? There is nothing to worry about the database fine as long as your application have right connection string to point to your database.
Application files and folders
Again this doesn't really matter where application files and folders resides in the client machine. It's upto the users to decide where he/she likes to install the application.

You cannot install from backup. Also in your scenario, you should force end user t install Sql Express, what If it has already installed. So You need considering , scripting of entire database. You can create another exe / look for option in Installshield to execute that Script incase the database server is found else, force user to download the Sql Sever Express or Embedd it into setup and execute the script over there. But that will make your Setup Size more than 100's of MB.

Related

Clickonce deployment with SQL Server CE

I manage to finish my project and publish it for deployment on other machines. My C# WPF application have SQL Server CE as its backend database. I wanted the database to be able to work in other machine that have no SQL Server CE installed. I publish it using clickonce, the publish was successful. However when I run it on other machines, and tries to open the database there is an error prompt that said 'database file cannot be found. Check the path to the database [Data Source=D:db.sdf]. I followed the tutorials on clickonce by mdsn, Microsoft and by other people, the result is always the same. The local database cannot be detected.
D:db.sdf is not created by ClickOnce, you must have changed something. ClickOnce by default installs data that is included in a project to a directory in the app folder, and sets the DataDirectory app domain value to the path to this directory. In your application you should use something like
SqlConnection("Data Source=|DataDirectory|db.sdf;...")
Note that DataDirectory may not be writable by users. If you want users to save data you should copy |DataDirectory|db.sdf to some place writable like
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

DO I need to setup sql server in a computer to run c# desktop application file made in vs 10?

I have a desktop application made in vs 10 with sql server 8. I have added the mdf file in app_code folder of project and the app.config is changed accordingly.The application is published and is availabel as setup file(.exe).If i want to install it in another pc, do i need to install the sql server in that pc?
The short answer is Yes
The idea is database needs a server to host it and an engine to run it
mdf file has no value without sql serve and access files has nothing to do if you don't have MS Access installed, etc.
But this does not mean db server must be installed on the client machine that has the application. as it can be on another machine or on the cloud (i.e. hosted on the internet)
As long as your application is connecting to that machine/server

Deploying and SQL Server CE file along with Win Forms Application In VS 2010

I have created a Winforms application using visual studio 2010 in C#.
I created a local SQL Server CE file (.sdf) and added it to my project. Initially, I had a problem as during the course of my application, I was writing data to the database and when I checked in the server explorer, the database always seemed empty but the data values were correct.
I then realized, that the database gets copied to the bin and when I checked that database file, I could see all my data over there.
My connection string is currently
conn = new SqlCeConnection("Data Source =KHDASurvey.sdf");
Now the problem arises when I want to deploy the project to a client's machine. I do not want them to have to install any files or any environments of any sort and I want all the files that are needed to be deployed.
I came across two ways to deploy a project:
the one click method outlined here: here
then another one using setup project here
I like the set up project option so when I run it the user can select where the application
exe file will reside.
I add the files and content to the setup project and then I built it. I create an installer and then I execute it.
When the application is created, I see the .exe and I even see a .sdf file residing in the
same location.
But the application data will only remain while the application is running, then after that I get empty values as it seems nothing is either getting written, read or both. As shown
before, my connection string is set so that it reads from the db file locally.
I have really looked all over for several solutions, I did not find one which completely
explains it. I saw something about altering the connection string in app.config but I am
not really using it in the code, the connection string that is.
Please give me some suggestions or point me in the right direction.
Thank You

Deploying C# application with SQL database

I have developed a C# application with SQL database, now i want to package it with the database and deploy it on some other machine which does have sql installed. How should i go with it.
What should be the connectionstring for the project, currently i am using "initialcatalog".
Pls Help
I am not sure, if I understand the question well.
If this is a C# class library only, you can get the dll and deploy in the required application.
If this is a web application, you can either create a web deployment package or publish the site.
For SQL migration, you can used the database publishing wizard from microsoft.
http://www.microsoft.com/en-in/download/details.aspx?id=5498
I hope my answers helped you.
Make .bak file of your SQL database.
Publish c#.NET application.
In the folders where you programmed this application, you will find published setup of your application.
Complete wizard in that publish setup folder.
upload database backup file(.bak) where you want to install application.
In this way you can deploy your application.
there are some install maker tools like install shield, which you can make a setup for your application,
About your connection string if your sql server is on your local computer you should set the "DataSource = . "
somthing like this : "Data Source=.;Initial Catalog=yourDBName;User ID=sa;Password=1"
the dot means local computer.
to create your data base on the target computer you can right click on your database and select task\generateScript and follow the wizard to make your database script the run that script on the target computer.
It's a common practice to include mdf or sdf file directly in solution (at least that's how are a lot of MS examples like Northwind/AdventureWorks are done). So you need to detach your db and then simply reattach it to other db server. You can read more here http://goo.gl/0FV1N
You can create a set of SQL Scripts to build the database via T-SQL or you could create a script to attach a new database to the server using the MDF/LDF files you include with your project.
Examples:
C# use script to create database
http://support.microsoft.com/kb/307283
Regardless of how you do it, you'll first need to establish a connection to the SQL Server with rights to create a new database. You might want to prompt for these values during install or on the first launch of your program.

Setup SQL Server for database made in c#

I have a problem, I made a nice application in C# with a SQL database, now I wanted to install that application on another pc but it doesn't connect to database file. Is there a nice way that I can install that database and connect to it with only changing connection string in my program. Is there any way that I can access the database through network? I tried to find some tutorial but without luck..
I would suggest you to append the database file (which ever it is) to your project. So it will be located inside the project`s folder.
But before Publishing the application, change the connection string, instead of a full path use |DataDirectory| . This is an example:
//from
#"....Database=C:\MyProject\MyDataBase.mdf;...";
//change to to:
#"....Database=|DataDirectory|\MyDataBase.mdf;...";
This way you will not have issues with connection string.
But dont forget to ADD the database file to your project (incuse it in it).
You need SQL Server Express to connect to database files. You have this installed automatically with visual studio, but another computer may not have it. Make sure that another computer has SQL server installed.

Categories

Resources