Reputation: 949
I am converting my application to use MSOLEDBSQL from SQL Server Native Client 11.0
I have changed my connection string from "Driver={SQL Server Native Client 11.0}" to "Provider=MSOLEDBSQL" along with UID,PWD,Server,Database parameters.
But I could not able to connect to the Database and getting "[Microsoft][ODBC Driver Manager] Dialog failed"error message when using SQL_DRIVER_COMPLETE.
IM008 Dialog failed The driver attempted to display its login dialog box and failed.
WindowHandle was a null pointer, and DriverCompletion was not SQL_DRIVER_NO_PROMPT.
Similarly, when used SQL_DRIVER_NOPROMPT, it throws an error "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".
IM002 Data source not found and no default driver specified (DM) The data source name specified in the connection string (InConnectionString) was not found in the system information, and there was no default driver specification.
(DM) ODBC data source and default driver information could not be found in the system information.
The above errors are returned as a result of a call to SQLDriverConnect().
I have downloaded and installed https://learn.microsoft.com/en-us/sql/connect/oledb/download-oledb-driver-for-sql-server?view=sql-server-ver15 and could see the binaries in the system32 folder.
As per MS Docs, registry settings will be done as part of the installation.
All appropriate registry settings for the OLE DB Driver for SQL Server are made as part of the installation process.
Should we do any additional registry configuration or other settings in order to use the MSOLEDBSQL driver ?
When I use the Driver keyword as mentioned above it works for native clients. But if I used "Provider=SQLNCLI11" it fails. Any thoughts on this ?
I suspect the problem is related to loading the driver.
Appreciate it if anyone could help in fixing this issue.
Thanks in Advance.
Upvotes: 2
Views: 12367
Reputation: 1801
I had the same error connecting to Azure SQL Server using C++.
Check your connection string.
DRIVER={ODBC Driver 18 for SQL Server};Server=${HOST},${PORT};DATABASE=${DATABASE};UID=${USER};PWD=${PASSWORD};Authentication=SqlPassword;Encrypt=No
I had to turn off Encryption for SqlPassword authentication to work.
Then use the SQL_DRIVER_COMPLETE flag and not SQL_DRIVER_NOPROMPT as advised in the Official Documentation here.
SQLDriverConnect(hDbc, nullptr, connStr, SQL_NTS, nullptr,
0, nullptr, SQL_DRIVER_COMPLETE);
Upvotes: 0