Create setup file with SQL Server database in VB2010 - visual-studio-2010

I made a demo project in vb2010 using database interaction with SQL Server 2008 R2. Created a setup file for that project and installed and executed successfully on my PC. Copied that setup file on another PC and tried installing. But couldn't run it because SQL Server 2008 R2 was installed in that PC.
My question is that how can we create a setup file with database so that we need not install SQL Server 2008 R2..? Because, let's assume that I am developing a software for my client. What if my client doesn't have SQL Server installed on his PC? It will be useless to install the whole SQL Server for a small application. How can we achieve that?

It will be useless to install the whole SQL Server for a small application.
That's exactly right. Sql Server is not intended for use as a private data store for a single-user desktop application. If that's what you want, you can use Sql Server Compact Edition, Sql Server LocalDB, Sqlite, or even ~gasp~ MS Access. But don't use the full edition of Sql Server; not even Sql Server Express Edition. The full version of Sql Server is just that: a server, intended for use in a shared environment where you have many users talking to the same data source.

Related

Can't add Local Database to project

This might be a really dumb question... but in VS2013 when trying to add a local database to my Windows Forms Application Project the option is now shown in the C# items menu. The only DB that is available is a Service-Based DB. From what I understand, this is related to SQL Compact Edition but I do have SQL Server 2012 installed. Any ideas? Or are there any significant differences between the Local DB and Service-Based DB?
A service-based database is a database that is only accessed through a server. It uses an MDF data file, which is SQL Server format. To be able to connect to a SQL Server database the SQL Server service must be running, because it's that that processes your requests and access the data file.
A local database is one that is local to your application only. It uses an SDF data file, which is SQL Server CE (Compact Edition) format. There is no need to install a server to access an SDF database. You simply distribute the DLLs that constitute SSCE along with your app and access the data file directly.
You'd normally only use SSCE if the data was to be accessed by your app only and there was a relatively small amount of data. For your project you would use SQL Server. For testing purposes you can use the free Express Edition. When deployed you might still use SSEE or you might use a full version of SQL Server. Note that Microsoft include SSEE with their own RMS POS software. SSEE is limited to databases of 4GB though, so even if you start out with SSEE and it can handle the load, you may still have to upgrade at some point in the future based on data capacity.
Source of info:jmcilhinney post.
for help on creating the database have a look at this tutorial it may be of some help.
Hope this info helps you :)
It turns out VS2013 dropped the .sdf format.
Is Microsoft dropping support for SDF database files in Visual Studio?
The answer is yes: Microsoft is silently dropping support (as usual IMHO) to Sql Compact Edition.
It started abandoning Sql CE 3.5 in Vs2012 It continued dropping Sql CE in Sql Management Studio 2012 and finally in VS2013
You can use CompactView or install SQL Server Compact Toolbox extension in VS2013 or (my prefered solution) use Sql management Studio 2008
UPDATE thanks to Nicolas' comment
As stated by Microsoft:
SQL Server compact edition is in deprecation mode with no new releases planned near future. Last release SQL CE 4.0SP1 (and earlier releases that are still in the support cycle) will continue to be supported through its lifecycle and Microsoft is committed to fix any major, production blocking issues found in these releases.
Have you tried adding your local database from inside the project? Have a look and see if you can add your database from datasources.

Connecting to end user's SQL Express during installation

I have been writing SQL Compact C# winforms applications for a while now, with the help from all the wizards in Visual Studio. The database is created during development, and installed as-is. Then suddenly, I realise I actually have no clue how to connect to SQL Express on client's machine and install a database if I had to.
There are many examples on connection string and creating database in SQL Express via code (C# in my case) but I don't think that is what I am looking for.
If I develop an application that requires SQL Express. I know there's a feature in Visual Studio that detects and install SQL Express if it does not exist. However, how do I set up and install my database in SQL Express? Do I need to somehow get credentials somewhere?
You mention both SQL Server Compact Edition and SQL Server Express Edition; these are two different things, but for the case you've described you probably mean SQL Server Compact Edition.
SQL Server CE comes with the .Net Framework, so no install should be required. However, you will have to create a database. You can do that with SqlCeEngine.CreateDatabase().
EDIT
For SQL Server Express... to get a connection string from the user without them having to actually type in a connection string, you can use a data connection dialog: archive.msdn.microsoft.com/Connection

Install a SQL Server database to a client's machine

I need to install a SQL Server 2008 database on several user machines. The users are not technically proficient, so I cannot create a script and just give it to them. I need to be able to create an executable that will create the database. The executable will check if the user has SQL Server 2008 Express installed, then install the database. The executable will install the database using Integrated Security, so I don't need the user's id or password.
I tried using the database project in Visual Studio 2010, but it just creates scripts.
Is there an open source solution to creating an executable that installs SQL Server databases?
May I suggest that you look at embedding SQLServer 2008 Express within your application.
Check the Microsoft link here.
Then you can check for an SQL instance and install one if it doesn't exist when the program first starts up.
A simple way would be to use SQL Server Management Objects (SMO) to create a .NET console application that creates the database.
Depending on your security rights on your user's machines you may be able to run the app from your workstation and deploy directly to their machines.
SMO can also be driven by powershell.

How is Visual Studio 2010 connecting to SQL Server 2008 if I don't have the native client installed?

I have MS VS 2010 installed on my Windows 7 but, I don't have the SQL Server Native client installed in it.
After loading Visual Studio I do click menu Data / Transact-SQL Editor / New Query Connection.
The SQL Server 2008 R2 login dialog will show up, I type server name, select SQL Server authentication, type username and password and click connect. The connection is established and an editor window shows up and I'm ready to query!
I understand the SQL Server 2008 native client files are sqlncli10.dll, sqlnclir10.rll. I did search for these files in my entire hard drive and they weren't found.
So, how is Visual Studio 2010 connecting to SQL Server 2008 if I don't have the native client installed?
Is VS 2010, when connecting to SQL Server 2008, using .NET Framework assemblies?
The .NET Framework already contains the Sql Server (and other) Database clients.
Have a look at System.Data.SqlClient
If NO native client is installed, Visual Studio 2010 is using the .NET Framework version 4.0 to connect to SQL Server 2008 R2 when connecting through menu Data/Transact-SQL Editor/New Query Connection.
I verified and it is loading assembly System.Data.dll (located under C:\Windows\Microsoft.NET\Framework\v4.0.30319) to establish the connection to the server.
I have not installed the Native client 10.0 for SQL Server 2008 R2 and I'm not using it right now but, if installed, the native client files (sqlncli10.dll, sqlnclir10.rll, and s10ch_sqlncli.chm) should be found under
%SYSTEMROOT%\system32\
which are installed as part of the SQL Server installation.
There is also a redistributable installation program named sqlncli.msi, which should be found on the SQL Server installation CD under
%CD%\Setup\
The reference for installation details
http://msdn.microsoft.com/en-us/library/ms131321.aspx
And the reference for the SQL Server 2008 R2 Native Client Features
http://msdn.microsoft.com/en-us/library/ms131456.aspx
The key piece of information here is:
You do not need to install SQL Server Native Client on your client machine (in this case your dev box where Visual Studio is), in order for an application using ADO.Net, to connect to SQL Server.
The reason is as #dknaack said: the .Net framework contains the code required to make the connection. This is contained in System.Data.SqlClient.
SQL Native Client on the other hand is used by unmanaged applications to connection to SQL Server via either OleDB or ODBC providers.
In short:
System.Data.SqlClient - used for connections from managed code to SQL Server i.e an ADO.Net connection
SQL Server Native Client - used for connections from unmanaged code to SQL Server
Whilst you CAN connect to SQL Server from a managed app using SQL Server Native Client, it is not a recommended practice:
If you are developing a new application, it is recommended that you
consider using ADO.NET and the .NET Framework Data Provider for SQL
Server instead of SQL Server Native Client to access all the new
features of recent versions of SQL Server.
References:
https://learn.microsoft.com/en-us/sql/relational-databases/native-client/sql-server-native-client-programming?view=sql-server-2017
https://learn.microsoft.com/en-us/sql/relational-databases/native-client/applications/using-ado-with-sql-server-native-client?view=sql-server-2017

SQL Server 2008 (express edition) Configuration - with Active directory

I have 3 computers. I have installed windows server + Active Directory on one pc. There are two other PCs registered with active directory. Those two PCs have installed SQL server(express) 2008 and Visual Studio 2010 separately. Here is my network. :)
Now I want to communicate with SQL server to access db through my development machine. Do I have to install SQL in that machine too ?
How ever I need to use PC1 as my SQL server machine.
How do I connect to SQL db located in PC1 from PC2 ??
Thank You!!
Answers to your question
Now I want to communicate with SQL server to access db through my development machine. Do I have to install SQL in that machine too ? No
How do I connect to SQL db located in PC1 from PC2 ?? on your config file use this as the connection string.
Data Source=PC1Name\SQLEXPRESS;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
But if you want to view the data on PC1 without Visual Studio you need at least the SQL Server Management Studio Management Tools. If your useing express by default it is installed as an instance thats why the data source on the connection string is PC1Name\SQLEXPRESS. Usually the instance name is SQLEXPRESS.

Resources