Embedding SQL Server into a .NET application - sql-server

Hey, I've just finished writing a VB.NET application. Now I want to package the executable and the database ofcourse into a single installer file. I tried using QSetup, InstallShield to make SQL Server embedded into the setup file, and finally after hours of try&fail I have no idea. Anyone?

You can do a rightmouse on the properties of your Visual Studio Setup Project, and then there is this button 'Prerequisites'. There you can tick 'SQL Server Express ...' Or the 'SQL Server Compact 3.5'
link to image
You're probably best off just to set the connection file directly to the mdf, and attach it when the program is run. This is easier as it doesn't require a custom setup script to install the database to the database directory itself.
Note: Consider using the Compact Version, it's smaller, people don't like a full blown engine on their computer :)

InstallShield has a concept called Setup Prerequisites where you can teach it how to install additional packages along with your own. In older versions this would happen before calling your MSI. In newer versions you can have a "Feature" prerequisite where the prereq can associated to a feature and only installed if that feature is selected to be installed and after it's been selected but still before the main activity of your MSI occurs during the install execute sequence.
InstallShield also has a pattern for executing SQL scripts against your database instance so that you can then load your database into your newly installed instance.
All of this is quite powerful but it does take a bit of digging to learn.

As far as I know, anything but the SQL Server Compact Edition (SQL Server CE) cannot be embedded into your setup, really. Microsoft doesn't want that - you need to have SQL Server Express installed separately - any other edition can't even be shipped with your software (the client must have a license and installation separately).

You can indeed distribute SQL server with your custom application:
http://msdn.microsoft.com/en-us/library/bb264562(SQL.90).aspx

Related

Can't open properly a SSIS package based job from SSMS in Visual Studio

I need to understand what a certain job in SQL Server 2012 does. It's a job someone created and left the company before I started to work here, and nobody on my team knows what this job does also.
The job isn't SQL command based but SSIS Package (which I'm not familiar with), the package points to a Maintenance Plan with the same name as the job. As I read on the internet I connected via Integration Services type, then Stored Packages -> MSDB -> Maintenance Plans, right click on the Maintenance Plan and exported it to a .dtsx file.
I opened it in Visual Studio 2010 Shell, but I can't edit anything because of this error:
The task with the name "" and the creation name "" is not registered for use on this computer.
I also don't have a Solution Explorer for that package, and the icons of the tasks seem a bit faded compared to tasks icons of a new project if I create one.
Maybe the dated version of the VS can be the problem? Perhaps there is other way to see what this job does?
I never worked with SSIS before so maybe I'm missing something very basic but I've been on the Internet for days already and can't find any solution.
Please help,
Thanks in advance
By way of background, until Visual Studio 2019, VS, by itself, couldn't open an SSIS package.
Prior to VS 2010, you needed to use a different product, called Business Intelligence Design Studio (BIDS), which was based on VS, but was built for SQL Server functionality. With the release of SQL Server 2012, Microsoft created SQL Server Data Tools (SSDT) as a plugin for VS that required a separate installation. Until SSDT(VS) 2017, you needed to have stand-alone versions of BIDS or SSDT for each version of SSIS you were working with in your environment. The 2017 version, though, is backward compatible to SQL Server 2012, and forward compatible (!) to SQL Server 2019. Visual Studio 2019 has SQL Server Data Tools sort of built in, but you need to add extensions through the extension manager for SQL Server Integration Services (SSIS), Analysis Services (SSAS), and/or Reporting Services (SSRS).
That's kind of a lot to take in, and is sort of irrelevant to you, but it forms the context for Larnu's comments. Rather than messing around with antique versions of Visual Studio, you should just install either VS2017 and also SSDT, or VS2019 with the SSIS extension. Both are in current widespread use, so support is easy to find, and either will allow you to work with the 2012 package you're trying to open up.
Once you have the software installed, you should be able to create a "dummy" integration services solution that you can use to open random packages. I keep one around called MiscSolution. Right click on the solution name, select Add -> Existing Item. Then find your .dtsx package and import it. (Or right click SSIS Packages -> Add Existing Package. I always do it at the Solution level because that interface allows you to select multiple packages.)
Note that when you do this, you're making a new copy of the package in your local solution directory. You are NOT working on the copy of the package that sits in the folder where you picked it up. This matters if you're going to be making any changes, since it will need to be redeployed. It also matters if you accidentally hose up the package, because you've done no harm as long as you just delete that copy.
Once the package imports, which might take a minute or so depending on how complex it is, you should be able to open it up and see what's going on.

Portable SQL LocalDB or Express

For the testing purpose I need to have SQL Server configured on each dev machine.
So once test suite or case is started SQL Server should be accessible locally.
I can not share the common server (this can not be changed)
Compact Edition doesn't fit requirements - we have cross-DB queries which are not supported
Better not to have any pre-requisites for the dev environment (e.g. install SQL Server Express) - it is not preferable
Is there any chance to have portable Express/LocalDB editions? To start it manually before the test and to stop after?
If you have a recent version of Visual Studio installed you will also have SQL Server LocalDB installed. And it is not a service, but a process that will start on demand from another process.
I had to do a job with similar requirements as yours, they wanted to install the application on several computers but they wanted to process the data locally, use of a remote SQL Server was not an option for them (the files that they wanted to process had some sensitive information).
The best option for me due to the requirements was to use LocalDB 2012 and add it as pre-requisite on the APP installer, is just a matter of a few clicks and boom you have LocalDB 2012 working on that machine (the LocalDB MSI installer it's ~70mb).
Of course i had create the database and stored procedures if the database was not creater yet on that machine, nothing that you cannot when you start the application, hope it helps.

Doing clean install of SQL Server Express

I installed VS 2008, VS 2012 and the community version 2013 along with the matching SQL Servers but never needed the SQL Servers and never checked if they were properly installed.
I recently picked up SQL Server Management Studio and tried to connect to a server.
Unfortunately, it does not detect any local server, even though I have about twenty different entries in programs & apps for SQL Server related stuff including SQL Server 2012 and 2014 Express Localdb, an installation of SQL Server 2008, data-tier app frameworks, native clients, transact SQL, a couple "compact" versions, tools and what's not.
One would think that something in this mess would be recognized as a server, but apparently not so. I had an entry for SQL Server in the start menu with a nice GUI with an install DB option... that requested a server media folder (lord knows which). I tried starting manually one of the many SQL Servers (sqlservr.exe) from the program files folders to no avail (I get a message about a corrupt installation)
My DB experience is pretty much exclusively with MySQL and I am lost with all these applications that look like they should do something but don't.
I would like to have a bare bones installation that works for the following use:
Coding Winform apps with local databases (compatible with Entity Framework)
Allows to distribute the apps with local databases for free (commercial use, small data volume)
Running SQL queries from SQL Server Management Studio
What is the minimum I need for this purpose?
Should I uninstall all the existing SQL Server related programs and make a clean install from a single install file (for instance, would installing the 1.1gb SQL Server 2014 Management Studio Express 64 Bit.exe give me all I need)?
Or if not, is there any way to install a recent version and ignore the underlying mess? (I don't really care for the disk space, I just want this thing to work).
I apologize if this question is a mess but I am pretty confused with this, and I could really use a hand figuring out what's what.

Setup and Deployement in VB.Net having Sql Server Database in the Project

I have completed my Project in VB.Net and has published my project.
But i want to come out of these things
I have Sql Server Database in my project and i want my setup to add that database to sql server on installing my project.
I want my application to automatically detect sql server 2008 r2 and if it is not instaled i want it to install for me and then atach the database.
I dont want to add the database as a Attached database in my project.
i dont want to install crystal report in my application.
I have some unused refernces in my application in my project which i want to removed, i have tried the default visual studio remove unused references but still have some references like shockwave.dll log2net.dll etc.
The first step would be to switch to an MSI-based installer. This should allow you to resolve issues 3 and 5 (you control what the MSI includes). You can use a Visual Studio setup project, WiX or a commercial setup authoring tool.
For installing your database (issue 1), the best approach depends on how you use your database. Some installers simply copy the database files, others install it using custom actions and others execute SQL scripts. You should first determine how you want to install it and then ask a more specific question if you encounter problems.
To install SQL Server when it's not found (issue 2), you can use a prerequisite. This is done differently for each setup tool, so you first need to decide on a tool and then research how it supports prerequisites.
For issue 4, I'm not sure I know what to say. An MSI package will install what you include in it. If you don't add Crystal Reports in your package, then it won't be installed.
Visit
http://www.codeproject.com/Articles/10032/Deploy-SQL-Server-databases-easily-with-an-Install
Deploy SQL Server databases easily with an Installer class
Best regards!
Elias Sant Anna

How do I reference SSIS on a build machine without installing SQL Server 2008 Client Tools?

I need to build SSIS packages on a build machine, and do not want the overhead of installing SQL Server Management Studio on this machine. A SQL Server 2008 SDK would be ideal, but I could not find where to download it.
The dlls I require are (for example):
Microsoft.SQLServer.ManagedDTS
Microsoft.SqlServer.PipelineHost
Microsoft.SqlServer.DTSPipelineWrap
Microsoft.SQLServer.DTSRuntimeWrap
I could attempt to copy them to the build machine individually, but I would rather just use an SDK if possible.
Where can I get the SDK, or alternatively, what suggestions are there?
You could probably manually copy things about and register then in the GAC, but the client tools are hardly huge, and don't take long to install, so I don't see why they are much of an overhead?
As far as I know there's no other way to get those assemblies.
I think he is trying to accomplish SSIS packages as part of the automated continuous build process. The way i did it was to have an express edition of SQL Server and SSIS on the build machine, use BIDS helper to script the cmd line file for deploying the packages and use NANT to use this script. Hope this helped.
I don't know about SQL 2008 but SQL 2005 SSIS packages are developed in Visual Studio.
Edited:
When you run install for client tools, it's an option to add the stuff to VS.NET, "Client tools" as such can be deselected (end edit)
SSMS can be used to manage them and administer.
What other editor did you want to use...?

Resources