Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ADO Connection String.

ADO Connection String.

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasesecurityhelpsql-server
4 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    forexsurfr
    wrote on last edited by
    #1

    I am currently having problems with my ADO connection string. I have searched all over the internet for a solution to this problem but I have yet to find a solution. Can someone help me with the proper configuration for a SQL OLEDB connection with a windows authentication? Included is my C++ code file. I cannot include my SQL Server signon but can send a printscreen via e-mail attachment. // ConnectionString.cpp : Defines the entry point for the console application. // #include "stdafx.h" // ConnectionStringSampleCpp.cpp // compile with: /EHsc //#import "msado15.dll" no_namespace rename("EOF", "EndOfFile") #import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EOFile") // Function declarations inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);}; void ConnectionStringX(); _bstr_t GetState(int intState); void PrintProviderError(_ConnectionPtr pConnection); void PrintComError(_com_error &e); int main() { if (FAILED(::CoInitialize(NULL))) return 0; ConnectionStringX(); ::CoUninitialize(); } void ConnectionStringX() { // Define Connection object pointers. Initialize pointers on define. These are in the ADODB:: namespace _ConnectionPtr pConnection1 = NULL; _ConnectionPtr pConnection2 = NULL; _ConnectionPtr pConnection3 = NULL; _ConnectionPtr pConnection4 = NULL; // Define Other Variables HRESULT hr = S_OK; try { // Open a connection using OLE DB syntax. TESTHR(pConnection1.CreateInstance(__uuidof(Connection))); //pConnection1->ConnectionString = "Provider='sqloledb';Data Source='(local)';" // "Initial Catalog='DSNPubs';Integrated Security='SSPI';"; //pConnection1->ConnectionString = "Provider='sqloledb';Server='PCD-LT-MCERTINI\\SQLEXPRESS';" // "AttachDbFilename='C:\\SQL Server 2000 Sample Databases\\NORTHWND.mdf';Initial Catalog='northwind';Trusted_Connection=Yes;"; pConnection1->ConnectionString = "Provider='SQLOLEDB.1';Persist Security Info='True';User ID='mcertini';Initial Catalog='northwind';Data Source='PCD-LT-MCERTINI\\SQLEXPRESS';"; //pConnection1->ConnectionString = "Provider='SQLNCLI10';Data Source='NORTHWND.mdf';"; pConnection1->ConnectionTimeout = 30; pConnection1->Open("", "", "",adConnectUnspecified); printf("cnn1 state: %s\n", (LPCTSTR)GetState(pConnection1->State)); // Open a connection using a DSN and ODBC tags. // It is assumed that you have create DSN 'D

    R F 2 Replies Last reply
    0
    • F forexsurfr

      I am currently having problems with my ADO connection string. I have searched all over the internet for a solution to this problem but I have yet to find a solution. Can someone help me with the proper configuration for a SQL OLEDB connection with a windows authentication? Included is my C++ code file. I cannot include my SQL Server signon but can send a printscreen via e-mail attachment. // ConnectionString.cpp : Defines the entry point for the console application. // #include "stdafx.h" // ConnectionStringSampleCpp.cpp // compile with: /EHsc //#import "msado15.dll" no_namespace rename("EOF", "EndOfFile") #import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EOFile") // Function declarations inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);}; void ConnectionStringX(); _bstr_t GetState(int intState); void PrintProviderError(_ConnectionPtr pConnection); void PrintComError(_com_error &e); int main() { if (FAILED(::CoInitialize(NULL))) return 0; ConnectionStringX(); ::CoUninitialize(); } void ConnectionStringX() { // Define Connection object pointers. Initialize pointers on define. These are in the ADODB:: namespace _ConnectionPtr pConnection1 = NULL; _ConnectionPtr pConnection2 = NULL; _ConnectionPtr pConnection3 = NULL; _ConnectionPtr pConnection4 = NULL; // Define Other Variables HRESULT hr = S_OK; try { // Open a connection using OLE DB syntax. TESTHR(pConnection1.CreateInstance(__uuidof(Connection))); //pConnection1->ConnectionString = "Provider='sqloledb';Data Source='(local)';" // "Initial Catalog='DSNPubs';Integrated Security='SSPI';"; //pConnection1->ConnectionString = "Provider='sqloledb';Server='PCD-LT-MCERTINI\\SQLEXPRESS';" // "AttachDbFilename='C:\\SQL Server 2000 Sample Databases\\NORTHWND.mdf';Initial Catalog='northwind';Trusted_Connection=Yes;"; pConnection1->ConnectionString = "Provider='SQLOLEDB.1';Persist Security Info='True';User ID='mcertini';Initial Catalog='northwind';Data Source='PCD-LT-MCERTINI\\SQLEXPRESS';"; //pConnection1->ConnectionString = "Provider='SQLNCLI10';Data Source='NORTHWND.mdf';"; pConnection1->ConnectionTimeout = 30; pConnection1->Open("", "", "",adConnectUnspecified); printf("cnn1 state: %s\n", (LPCTSTR)GetState(pConnection1->State)); // Open a connection using a DSN and ODBC tags. // It is assumed that you have create DSN 'D

      R Offline
      R Offline
      Rane
      wrote on last edited by
      #2

      Could you post the error/problem that you are getting/facing while trying to establish the connection? -Rane

      1 Reply Last reply
      0
      • F forexsurfr

        I am currently having problems with my ADO connection string. I have searched all over the internet for a solution to this problem but I have yet to find a solution. Can someone help me with the proper configuration for a SQL OLEDB connection with a windows authentication? Included is my C++ code file. I cannot include my SQL Server signon but can send a printscreen via e-mail attachment. // ConnectionString.cpp : Defines the entry point for the console application. // #include "stdafx.h" // ConnectionStringSampleCpp.cpp // compile with: /EHsc //#import "msado15.dll" no_namespace rename("EOF", "EndOfFile") #import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EOFile") // Function declarations inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);}; void ConnectionStringX(); _bstr_t GetState(int intState); void PrintProviderError(_ConnectionPtr pConnection); void PrintComError(_com_error &e); int main() { if (FAILED(::CoInitialize(NULL))) return 0; ConnectionStringX(); ::CoUninitialize(); } void ConnectionStringX() { // Define Connection object pointers. Initialize pointers on define. These are in the ADODB:: namespace _ConnectionPtr pConnection1 = NULL; _ConnectionPtr pConnection2 = NULL; _ConnectionPtr pConnection3 = NULL; _ConnectionPtr pConnection4 = NULL; // Define Other Variables HRESULT hr = S_OK; try { // Open a connection using OLE DB syntax. TESTHR(pConnection1.CreateInstance(__uuidof(Connection))); //pConnection1->ConnectionString = "Provider='sqloledb';Data Source='(local)';" // "Initial Catalog='DSNPubs';Integrated Security='SSPI';"; //pConnection1->ConnectionString = "Provider='sqloledb';Server='PCD-LT-MCERTINI\\SQLEXPRESS';" // "AttachDbFilename='C:\\SQL Server 2000 Sample Databases\\NORTHWND.mdf';Initial Catalog='northwind';Trusted_Connection=Yes;"; pConnection1->ConnectionString = "Provider='SQLOLEDB.1';Persist Security Info='True';User ID='mcertini';Initial Catalog='northwind';Data Source='PCD-LT-MCERTINI\\SQLEXPRESS';"; //pConnection1->ConnectionString = "Provider='SQLNCLI10';Data Source='NORTHWND.mdf';"; pConnection1->ConnectionTimeout = 30; pConnection1->Open("", "", "",adConnectUnspecified); printf("cnn1 state: %s\n", (LPCTSTR)GetState(pConnection1->State)); // Open a connection using a DSN and ODBC tags. // It is assumed that you have create DSN 'D

        F Offline
        F Offline
        forexsurfr
        wrote on last edited by
        #3

        The following is the error message I am receiving: Error number: 80040e4d Login failed for user 'mcertini'. Error Code = 80040e4d Code meaning = I Source = Microsoft OLE DB Provider for SQL Server

        R 1 Reply Last reply
        0
        • F forexsurfr

          The following is the error message I am receiving: Error number: 80040e4d Login failed for user 'mcertini'. Error Code = 80040e4d Code meaning = I Source = Microsoft OLE DB Provider for SQL Server

          R Offline
          R Offline
          Rane
          wrote on last edited by
          #4

          This error message is self-explanatory. Check whether your DSN is setup correctly. Any incorrect DSN(UserID/Pwd) will lead to this error.In addition Pl check if you have right level of access to the database. -Rane

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups