Connection String to SQL Server 2012 - sql-server

Currently I have a connection to server 2000 in a VB6 script using this...
Provider=sqloledb;Server=servername;Database=mydatabase;User Id=myid;Password=mypassword;OLE DB Services=-2;
And everything works fine with this as it always has. This has been running good for years.
I am now trying to connect to Sql Server 2012 from the same VB6 script using this:
Provider=sqloledb;Server=servername;Database=mydatabase;User Id=myid;Password=mypassword;
Everything works good here and I am able to write to the database just fine except while some of the scripts are running I get errors intermittently while the script is writing to the database. This is the error:
dbnetlib.connectionopen (connect()).]Sql server does not exist or
access denied.
I have to hit ok and then it keeps running. Can I avoid this or fix my connection string?
I also tried to fix this using a new connection string of:
Provider=SQLNCLI11;Server=servername;Database=mydatabase;User Id=myid;Password=mypassword;
But this gives me an error of:
run time error 3706 provider can not be found it may not be properly
installed.
Can anyone please help me improve either one of the connection strings that I am trying to use above to connect to sql server 2012.

Related

How do I connect to SQL Server from Windows without using trusted_connection?

Struggling with this problem. Right now I am building a service app on a windows machine, which I have been using the following line of code to connect to SQL Server
dbConnect(odbc::odbc(), .connection_string = paste0('driver={SQL Server};server=', SERVER, ';trusted_connection=true'))
It works great, but my issue is that this application I am building will be used on iOS and eventually a Linux container, so I cannot rely on "trusted_connection" going forward. But, the following code fails for me:
dbConnect(odbc::odbc(), .connection_string = paste0('driver={SQL Server};server=', SERVER, ';UID=',USER,";PWD=",PWORD))
In that line I removed "trusted_connection" and put in my user name and password that I use to log into my windows machine, but I get this error:
Error: nanodbc/nanodbc.cpp:950: 28000: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'fhcrc\sgreenle'.
The user is what I see when I connect to the server through SQL Server Management Studio, and the passwords match, but somehow I still have this error.
Any advice on how to debug or figure this out would be amazing. This has been a thorn in my side for a while and I cannot solve it for the life of me, and I fear that my project will be dead in the water without a solution.
When providing username and password in the connection string, you are using SQL Authentication. Your code sample shows that you are trying to use your Active Directory account for SQL Authentication, but this will not work. You need to create a separate SQL Server account using SQL Authentication and enter those credentials instead. Helpful reference: https://learn.microsoft.com/en-us/sql/relational-databases/security/choose-an-authentication-mode

SQL Server throws named pipe errors all of sudden

I'm running SQL Server 2014 Express and using the SQL Server native drivers for the connection from my VS.net code. These are both on my Win10 machine.
Suddenly, in the last week or so, I've been receiving errors when my code attempts to connect. Of course the dialog doesn't allow cut-n-paste, so helpfully this is correct:
Named Pipes Provider error 40 - Could not open connection to SQL Server
This only happens about 1 in 10 times that I run the app. If I simply stop it and re-run it, it instantly connects. Another machine in the office running Win7 and SQL Server 2012 started showing the same behaviour, but fails all of the time now.
Note: yes, the server is running, the firewall is configured properly, as is the server's connections, the browser is up, etc. It's important to note that these would cause it to fail 100% of the time.
Does anyone have any ideas what's going on? Was there a recent driver update that might cause this perhaps?

Log Parser SQL Connection String

Im am currently attempting to use log parser to import some data from windows event logs. I've run the command through on my local machine and sql instance but when I attempt to run on the live server it errors.
The issue seems to be related to the server name as i get a connection string error. My machine is named FF-IT05, but the live server is Omega/Reports. I've tried wrapping the server string in {} and [] (and nothing at all) but it still erros.
Does anyone know the syntax for the above server string??

ssrs DB connection error

I'm Trying to created a shared Data source from a sql server that is not local. the host of SSRS is a sql server 2014 and the DB source is a sql server 2008 R2.
I'm getting the same error whatever I do, which is
"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
I know everything is correct because even though I get this error when I run the report, in MSSQL report builder when I create a dataset and go to query designer and run the query it actually runs without any issues.
furthermore also in report builder when I try to do a connection embedded in my report and when I'm in the connection builder (connection properties) and I test the connection from there it gives me "the test connection suceeded" however when I click ok, go back to the datasource properties, and click "test Connection" it fails and gives me the error above.
If I try to test a shared connection on the server it will fail too.
I've tried connecting in many different ways (using windows athentication (my user is admin on the server), SQL server authenticationm, promting, etc) but they all failed.
I've been at this for a while, the server is also accesed by a remote PHP server so I doubt there is any real issue on the SQL server. I've tried deactivating all of the firewalls I saw but I doubt it's a firewall issue since I"m able to do all these connections.
the issue was the port 1433 that didn't work between the SSRS server and the datasource server. however it did work between my computer and the sql server.
what was happening is that when I tested the connections, the first test was a quick test and went through my computer to test the connection thus it was sucessfull. when it did the real test it went through the SSRS server and it failed there.
the same logic applies when I did my requests, when I tested the dataset it worked because in report builder it went directly to the database through my computer, when I tried to run the report it went through the SSRS server and failed there.
so there is some issue with the firewall even though it is turned of on both servers it's the connection between the two that isn't working.

SQL Server Error 26 When Using TableAdapter.FIll

When I am in the Dataset Designer and I ask to Preview Data on a Fill query all is well and data is displayed. When I try to use the TableAdapter.Fill method inside a program I get an exception for Error 26. This code was copied down from Team Foundation Server and the Connection Strings were changed to reflect the new server. All works fine on the old server.
I wrote another short program on the new server, added the same SQL Server Datasource and all is well, I can fill a Table Adapter.
Visual Studio Professional 2013, Sql Server Express 2008 R2, Sql Authentication in both programs.
I should also add that the code works fine in the original environment. The TableAdapter in the Designer displays the data from the database without a problem. It's only when I use an instance of that TableAdapter in my code that the Fill method throws an exception. I also get the same Exception when I use the GetData Method.
Any ideas?
SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified
This error is related to Sql Server Connection string, check your connection string specified in web.config
1) Make sure your server name is correct, e.g., no typo on the name.
2) Make sure your instance name is correct and there is actually such an instance on your target machine. [Update: Some application converts \ to . If you are not sure about your application, please try both Server\Instance and Server\Instance in your connection string]
3) Make sure the server machine is reachable, e.g, DNS can be resolve correctly, you are able to ping the server (not always true).
4) Make sure SQL Browser service is running on the server.
5) If firewall is enabled on the server, you need to put sqlbrowser.exe and/or UDP port 1434 into exception.

Resources