How To Deploy A Windows Application That Uses SQL Server (Standalone EXE) - c#

I currently access & write data to/from text files but want to make a move over to SQL Server (Also not yet sure which version). Note: This is a Windows Desktop, Windows Forms Application.
My application uses a DB (Single user) & I want to deploy JUST the EXE file, no additional DB/Access tables etc (I want to use SQL Server rather than MSAccess anyway).
What would be the best way to install the tables of the DB onto my users machines? (I also don't want to use MSI installers etc, JUST an EXE file).

Assuming there is an instance of SQL Server available on the client, you could use my company's product BuildMaster to create this EXE for you. Once you've installed it you can:
Install the SQL Server extension (Admin > BuildMaster Extensions)
Create a new Standard Application
Select "Configuration > "Database Connections" from the application menubar
Register a new connection with a fresh SQL Server database
Initialize the database within BuildMaster
Visit "Configuration > "SQL Change Scripts" from the application menubar
Choose "Add Change Script" to upload the script file(s) you'd like to make an EXE from
Once saved, you can select "Download Deployment Tool", this will generate a standalone EXE with the script contained within it
This generated EXE can run with optional arguments (e.g. a custom connection string) as specified in the Using the Change Script Package documentation. Also note that it will only run the scripts one time against the target database. For more information about that, you can read the change script documentation.
Not surprisingly, this is how we deploy BuildMaster's database itself; the tool is contained within the installer as an embedded resource and then written to disk and executed by the installer.

SQL Server isn't designed to be embedded into applications. Consider using an embed-able SQL database such as SQLLite or SQL Server Compact. You can also use certain methods to install SQL Server Express with your application.

Related

.Net Application Installation 2012 with database

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.

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.

How to create a setup package for C# Windows application with SQL server

I want to develop a Windows data driven application using C# and SQL server 2008. But I don't know after development of complete application how to create the setup file (Note: I know how to create setup using Visual Studio. But this way the setup file does not include the SQL server agent and may be .Net framework also) in which it contains all the required assemblies and files including SQL server and .Net framework.
Means I want the setup file that will install:
The Windows application
.Net framework
SQL server for connection only
Another question is how to solve the problem of connection string because at the time of SQL server installation, the instance name may be user specific, which means it might be different than my app.config file connection string datasource name.
Please suggest....
am using install shield, it allows you to customize the sql server setup with some arguments that the user won't see, the ones am using are
/ACTION=Install /FEATURES=SQLENGINE /INSTANCENAME=SQLEXPRESS /SQLSVCACCOUNT="NT AUTHORITY\SYSTEM" /ADDCURRENTUSERASSQLADMIN=True
you can specify all the instance name ...., you can also make a background setup by adding /q, for more arguments see http://msdn.microsoft.com/en-us/library/ms144259(v=sql.100).aspx

service based database

I have one problem with service base database, I have used it in one of my application but I dont know if user who'll use it need to have something installed to be able to run application (like you need to have installed NET framework for c# applications)
Note: This is windows application
It depends on what database engine you're using. SQL Server/SQL Express/Oracle/MySQL require you install the application on the machine before it'll work. databases engines like SQLite and Firebird are just Dll's, so you can include then in your project.
If the file is an MDF that's a SQL Server file - you need to install SQL server, or SQL express.
You can include it with your app and do it silently:
http://social.msdn.microsoft.com/forums/en-US/sqlsetupandupgrade/thread/7180e4dc-5c1e-4501-83d7-6882abb1f04e/
You will need to install the relevant database engine with the correct service name, and create the database and relevant objects on installation.

Initiate SQL Server Import/Export wizard?

Can the SQL Server Import/Export wizard be called from our windows application?
The data import/export wizard is an external app called "DTSWizard.exe", which lives somewhere in your SQL Server installation directories.
In my case, on a 64-bit system with SQL Server 2008 R2 CTP installed, I find it under:
"C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\DTSWizard.exe"
for the 32-bit version
or
"C:\Program Files\Microsoft SQL Server\100\DTS\Binn\DTSWizard.exe"
for the 64-bit version
You can definitely store those locations in some config file and then execute those from a Winforms app.
Marc
The wizard generates an SSIS package. You could save and use that in your application and use variables etc to control it (example: a filename chosen by the user).
Otherwise, you have absolutely no control over what data goes where in the wizard. Surely the load or export functionality of the application is in the context of what makes sense for you app, not do anything and drop it anywhere?
I am guessing here but I think that Import\Export wizard from SQL Managament Studio is simply a wrapper for command line tool called bcp.exe.
There is a lot information about bcp on the Internet so I will provide only one link here:
http://msdn.microsoft.com/en-us/library/ms175937.aspx

Categories

Resources