Connecting to end user's SQL Express during installation - 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

Related

SSIS Oracle connector

I am in the process of setting up a new SQL server 2019 standard edition. (due to price unable to go to enterprise edition)
The issue I am having is I have re-written a SSIS package that uses an oracle connector within the package to push data into my SQL server tables.
However when I run this in SSMS it returns an obvious error:
I have also tried to run this via CMD line however returns the same error.
My query is there a way for me to auto extract data from an oracle DB using SQL server 2019 Standard edition.
Due to license restriction we are unable to have VS installed on the server.
Any ideas would be much appreciated.
TIA

Would SQL Server Data Tools in Visual Studio 2015 allow Oracle DB connectivity?

I am using Oracle database for asp.Net web API application, I would like to build rdlc reports and I am not sure if SSDT for VS 2015 (SQL Server Data Tools in Visual Studio 2015) would allow Oracle database connectivity. If so, which version should I install?
Please advice what to install so that I can build rdlc reports.
Thanks
Nope. SSDT is strictly for SQL Server and when I asked last month, the team from Microsoft said that they have no intention of changing that.
It looks like you are talking about using SSDT to write reporting services reports against oracle rather than using SSDT to manage your oracle database. If I am right then you can create a connection to an oracle server:
See:
Data Sources Supported by Reporting Services (SSRS) - https://msdn.microsoft.com/en-gb/library/ms159219.aspx
You would still need a reporting services (sql server) instance to run the reports on but you can do it.
If you actually mean managing your oracle database using ssdt (deploying tables, procedures etc) then comment here and i'll delete this :)
ed
The Oracle Data Access Components (ODAC) with Oracle Developer Tools (ODT) supports Oracle data providers for .NET. SSDT uses these providers to create connection managers to access Oracle data.
http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html

Create setup file with SQL Server database in VB2010

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.

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.

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

Resources