Using SQL Server Native Client to access SQL Server LocalDB - sql-server

I'm trying to connect to a SQL Server LocalDB instance using the SQL Server Native Client driver. This is because we are looking to use Native Client in our production environment to gain access to the use of subject alternative names on SSL encryption for SQL Server. So far I'm not having much luck - is this a supported scenario? My connection string is:
<add name="Database" connectionString="Driver={SQL Server Native Client};Server=(localdb)\v11.0;Integrated Security=True;AttachDBFileName=|DataDirectory|Database.mdf;" providerName="System.Data.Odbc" />
The error I'm receiving is:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Any thoughts on how to connect?

In addition to using the 11.0 provider,
Did you create an instance of SqlLocalDb?
Did you start the instance?
If you are not the owner, did you try (localdb)\.\InstanceName?
I recently updated a bunch of content on the following Wiki page:
http://social.technet.microsoft.com/wiki/contents/articles/4609.troubleshoot-sql-server-2012-express-localdb.aspx
Also, your connection string states both native client and ODBC, is this intentional? And are you using AttachDbFilename on purpose?

You need to use a version of the Native Client that supports LocalDB. You're using version 9. Try:
Driver={SQL Server Native Client 11.0}
Microsoft called this out a long time ago:
Note that because the activation logic lives in the client-side provider, you need to install the latest one - SQL Server Native Client "Denali" (for ODBC and OLE DB) or the next .NET Framework (for ADO.NET).

Follows how I solve this after 3 days of hard research and trying, with my wishes for Happy Holidays and a great New Year:
on SQL Server Configuration Manager (SQLServerManager11.msc) at scaffolding on left:
a. right click on MS SQL Server Native Client(11.0 in my case)'s ‘Client Protocols’ and at right list, right click on TCP/IP for unenabling it allowing enable only 'memory sharing' (as rank order #1) and 'named piping' (as rank order #2);
b. stepping down on MSSQL SNC scaffolding, right click on 'Aliases' and at right list, exclude it fully blank;
c. you can repeat 'a' and 'b' for MS SQL SNC (32-bits) option of the scaffolding
reason: as a single local client on same machine of SQL Server LocalDb, there is no need for connecting through TCP/IP ports, being memory sharing or named piping more efficient options
on SQL Client Manager (cliconfg.exe) after choosing ‘General’ tab, keep 'Enable protocols in order' list at right unattended, fully blank and mark 'Enable memory sharing protocol' statement; then choose “Alias’ tab making ‘Server alias configuration’ list fully blank as well
reason: same as '1', now configuring client side
piece of cake now:
a. start MS SQL SNC by connecting to your localdb\instance - usually (localdb)\v11.0 – when required at SQL Server Management Studio (SSms.exe) starting and attach to wanted database or making this attachment through Visual Studio
b. start ODBC Administrator (odbcad32.exe), choose 'User data source' tab, click 'Add', on popup enter database name (generic, to be referred to later), database description (id.), 'localdb\instance' server name, click ‘Next’, ‘Next’ again, now mark ‘Change standard database to’ and at the list choose the wanted database connected and attached on ‘a’, click 'Next', click ‘End’; then on new popup click 'Test data source' for seeing it successful; it is done

Related

SQL Server Reporting Server data source connection fails when using Always Encrypted feature

We're using "Always Encrypted" feature in SQL Server to encrypt a few columns. Encryption works fine on MVC/SQL side. Only issue we have is with the SQL reporting server. Able to run the reports when the data source connection string is
Server=mssqlserver;Database=MYDATABASE;Integrated Security=true
But when I try to run the reports from the MVC application, it automatically adds the Column Encryption Setting=enabled to the connection string
Server=mssqlserver;Database=MYDATABASE;Integrated Security=true;Column Encryption Setting=enabled
When I enter the credentials and click 'Test Connection', it throws an error
Keyword not supported: 'column encryption setting'
Because of the above error, it cannot make a connection to the data source 'MYDATABASE'. Tried giving permission to the reporting server service account and the account used
to connect to the database to access the keys to encrypt/decrypt but no luck. How can I fix this issue? We're using SQL Server 2017.
This error is to do with the version of SSRS you are running. Under the covers, SSRS uses .net framework to connect to data sources. This version does not understand the keyword provided.
From the screenshot it looks like SSRS 2008R2, this targets .net 3.5. Always Encrypted (AE) is not supported until 4.6 (SSRS 2019). As far as I am aware you cannot change SSRS's target framework.
To get around this issue I suggest either:
1. Install an alternate data source provider that supports AE (i.e. Microsoft ODBC Driver for SQL Server 17.4 or above), then update the data source's connection string to use this
2. Upgrade SSRS to 2019
Hope this helps

Connect SQL Server from SQL Developer

I searched through all threads on the web available, but none could help me.
I am trying to connect to SQL Server engine from SQL Developer. In order to do that I enabled Named Pipes and TCP/IP from SQL Configuration Manager.
Then I tried different drivers:
I tried Microsoft JDBC driver for SQL Server - I cannot choose in connection manager SQL Server database type, so it does not work..
I tried jTDS driver instead, and it worked - I can choose SQL Server database type, but then all I get is an error informing that it cannot connect to Microsoft SQL Server on localhost (I tried localhost, name of my computer, none of which worked).
Is there anything more I can do?
EDIT
This is what I have so far:
SECOND EDIT
I had more problems:
With error saying
Status: Failur-I/O Error: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property
Using windows authentication, I still got asked for username and password.
(All details and solutions in my answer below)
We only support the jTDS driver for SQL Server and Sybase ASE connections, so that's the way to go.
After that, it's up to you to get a correct connection string to your SQL Server system.
Make sure you have the right port in addition to your 'localhost' network location for your SQL Server instance.
This is using version 19.1 of SQL Developer to connect to a SQL2012 instance overseas..
Actually there were more problems, which I'll post here along with solutions:
In order to ba able to connect SQL Server database type from SQL developer it is needed to install jTDS driver, as already mentioned. Other types are not supported by SQL Developer.
Next thing was to configure with SQL Configuration Manager (the easiest way IMO) SQL Server to listen on IP port 1433, not dynamic, as was previously set. In order to do that in configuration manager I had to go to SQL Server Network Configuration and make appropriate changes. More here.
Next I had problem:
Status: Failur-I/O Error: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property
Which was the fault of missing file, solution was placing file ntlmauth.dll to the /jdk/bin in SQL Developer directory.
I chose Windows authentication, which apparently is not supported by jTDS, so I needed to create user in SQL Server, which I use to connect SQL Server from SQL Developer.
After all that, I had it working.

How to connect to SQL Server 2014 installed on one PC from a 2nd PC without Windows server and domain involved?

I have a Toshiba laptop with Windows 7 on which I have installed SQL Server 2014 for my database and use Microsoft Access 2016 to manage the data in a user-friendly way.
Everything worked perfectly fine till I tried to connect to the database from another PC on the same network, also with Windows 7.
I am able to connect to the database from the second PC using Microsoft SQL Server Management Studio and SQL Server Native Client 11.0, logging in as sa using SQL Server authentication.
However, when I open the Microsoft Access database file from the second PC, a window pops up, saying that:
See this image.
And when I press OK a second window pops:
See this image.
I have configured the database to use a specific TCP/IP = 1433
Also made new inbound rules in windows firewall for all SQL Server services.
Please note that there is no domain involved here. I don't have a Windows server and the SQL Server is installed on PC #1.
If you require more information, please tell me, I'll be happy to provide
Hope someone will be able to help!
try to use LINKSERVER
Using SQL Server Management Studio
To create a linked server to another instance of SQL Server Using SQL Server Management Studio
In SQL Server Management Studio, open Object Explorer, expand Server Objects, right-click Linked Servers, and then click New Linked Server.
On the General page, in the Linked server box, type the name of the instance of SQL Server that you area linking to.
SQL Server
Identify the linked server as an instance of Microsoft SQL Server. If you use this method of defining a SQL Server linked server, the name specified in Linked server must be the network name of the server. Also, any tables retrieved from the server are from the default database defined for the login on the linked server.
Other data source
Specify an OLE DB server type other than SQL Server. Clicking this option activates the options below it.
Provider
Select an OLE DB data source from the list box. The OLE DB provider is registered with the given PROGID in the registry.
Product name
Type the product name of the OLE DB data source to add as a linked server.
Data source
Type the name of the data source as interpreted by the OLE DB provider. If you are connecting to an instance of SQL Server, provide the instance name.
Provider string
Type the unique programmatic identifier (PROGID) of the OLE DB provider that corresponds to the data source. For examples of valid provider strings, see sp_addlinkedserver (Transact-SQL).
Location
Type the location of the database as interpreted by the OLE DB provider.
Catalog
Type the name of the catalog to use when making a connection to the OLE DB provider.
http://www.quackit.com/sql_server/sql_server_2014/tutorial/linked_servers.cfm

Issue creating a connection to SQL server 2014 with ODBC data source and TLS activated

I am trying to create / modify a system data source for my application which needs to connect to our Microsoft SQL Express 2014 database through an ODBC data source.
The connection used to work before we enabled the SSL encryption flow but,
now that we have an encrypted link, the connection does not work anymore.
Here are some details:
We run Microsoft SQL Server express 2014 SP1 with the latest cumulative update (CU #3) (which was necessary so that we could deactivate SSL 3.0 and TLS 1.0 and run only with TLS 1.1 and TLS 1.2)
The database instance is a named instance, configured to run with a TCP/IP connection and a fixed port.
We enabled the "Force Encryption" option and configured the certificate through the "Sql Server Configuration Manager"
We can successfully establish a connection to the database either using Management Studio or the SQL command line utility
We disabled all usage of SSL/TLS prior to version TLS 1.1 done through Microsoft Schannel. This required us to update SQL Express 2014 SP1 to the latest cumulative update (CU #3)
The ODBC data source we try to configure (through ODBC data source Administrator) is a "System DSN" and uses the "SQL server" driver and target the exact same server name as the one working in management studio (and whose server name corresponds to the machine FQDN which is reflected in the certificate CN value)
The Version indicated for the SQL Server ODBC driver is "Microsoft SQL Server ODBC Driver Version 06.03.9600"
I am testing the connection directly through the ODBC data source Administrator tool.
The first test I runs are run on the exact same machine as the one hosting the database server.
We get two consecutive error message in the Microsoft SQL Server Login:
Connection failed:
SQLState : '01000'
SQL Server Error: 771
[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]ConnectionOpen(SECDoClientHandshake()).
Connection failed:
SQLState : '08001'
SQL Server Error: 18
[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]SSL Security error.
I went through all the literature I could find but cannot find a solution.
EDIT 27/01/2016 16:30
Following erg suggestion, I tried to use the last MS SQL Server Native Client version (11.00.2100 on my system), but it still does not resolve the issue. I experience another issue though (whether or not I force the strong encryption on the client side results in the same error):
Running connectivity tests...
Attempting connection
[Microsoft][SQL Server Native Client 11.0]TCP Provider: An existing connection was forcibly closed by the remote host.
[Microsoft][SQL Server Native Client 11.0]Client unable to establish connection
TESTS FAILED!
So, I finally got it working after struggling a little bit more.
First of all, it appears that there is another CU available (CU4) for SQL Server Express 2014 SP1.
I did download it and install it, but it did not resolve my problem: as soon as I deactivated TLS 1.0 and below version ODBC did not work.
Strangely, though the CU3 and installation of .NET 4.6 allowed me to successfully log in in Management Studio, when I tried to execute
the xp_readerrorlog query, it actually failed.
What I did to solve my issue was to follow malthus's answer on another related stack overflow question
https://dba.stackexchange.com/questions/93127/sql-server-service-won-t-start-after-disabling-tls-1-0-and-ssl-3-0 (3rd answer from the top).
I therefore activated the local security policy on my computer and managed to get the links to my SQL db working.
Now, I got IIS working along my own service and client working.
BTW, if somebody needs a more user friendly way of activating SSL/TLS version(s) and cryptographic algorithms on Windows, I stumbled uppon a nice GUI application which does not required to use regedit for it:
https://www.nartac.com/Products/IISCrypto. It's free and I am not a a Nartac Software employee, manager or shareholder.
I hope this will help!
EDIT Feb 25, 2016
It looks like the latest cumulative update (CU5 available at
https://support.microsoft.com/en-us/kb/3130926) removes the need to
activate the FIPS option for the System Cryptography.
I discovered this since I had to deactivate FIPS to enable another required
functionnality while still relying on a TLS 1.2 connection. Indeed, it
appears that activating the FIPS option for the System Cryptography prevents
.NET Framework to successfuly make use of some system algorithms (such as
SHA256Managed).
In addition, according to some discussions seen around the web (i.e.
http://blogs.technet.com/b/secguide/archive/2014/04/07/why-we-re-not-recommending-fips-mode-anymore.aspx)
it is not recommended to activate FIPS (except to strictly comply with
some governmental recommendations) since it breaks applications
relying on non-FIPS validated implementations of cryptographic
algorithms, which, however are provided in Microsoft system libraries.

SQL Server 2012 SSDT "The project could not be deployed to .... A connection cannot be made ...."

I'm a newbie to SQL Server 2012. Here is my condition.
I have a running SQL Server 2012 Business Intelligence SP1. The problem is I cannot deploy a project to my SSAS from another computer.
The error is:
The project could not be deployed to the 'DATABASE-SERVER\MSSQLSERVER' server because of the following connectivity problems : A connection cannot be made to redirector. Ensure that 'SQL Browser' service is running. To verify or update the name of the target server, right-click on the project in Solution Explorer, select Project Properties, click on the Deployment tab, and then enter the name of the server.
The following is the things that I've tried:
Check the target name on Project > Properties > Deployment > Target server.
Check the server service --> all SQL Server services are running.
The project can be deployed from server.
The connection to server is clear
I can connect to the Database Engine and Analysis Service from another computer from SQL Server Management Studio.
Please help me to fix this problem, I've been search for many days for this problem.
Thank you, sorry for my bad english.
Best regards, Stella.
I had the same problem, for me the solution was to explicitly specify login information on the Impersonation Information tab on the Data Source.
I know this is an old thread, but I had the same issue and I reckon more will run into this buzz saw.
My problem was that the remote installation of SSAS did not have an Inbound firewall rule for SSAS application; msmdsrv.exe.
Resolution:
Log on to the server running SSAS as Administrator
Launch Windows Firewall and advanced Security
Add Inbound Rule, give it a meaningful name like SQL Server - SSAS
Action: Allow the connection
On Program and Services Tab: For 'This Program' use Browse and identify msmdsrv.exe
For SQL Server 2014, it is by default here:
%ProgramFiles%\Microsoft SQL Server\MSAS12.SQLSVR14\OLAP\bin\msmdsrv.exe
(Very similar for 2012 and 2016, the numbers are different)
Click OK; You should see a green dot with check mark
Try your project again; It should connect, did for me.
NOTE: If this also work for you, consider going back to the Inbound Rule and consider adding connection restrictions for security reasons.
I solved mine by right clicking my data source (under Data Sources in Solution Explorer) → Edit in the General tab → In Connection Manager, do two things:
Change Server name from localhost to your computer name
Use SQL Server Authentication as Authentication, as opposed to Windows Authentication, and proceed to enter your user name and password (the "sa" password you use for SSMS).

Resources