Confirm SQL server connection was successful

1124650 pts.
Tags:
ODBC
SQL Server
To connect to our SQL Server, we've been using a C++ ODBC. Here's what we're trying to figure out. Once we've made the connection, how can we make sure the connection was successful? How can we validate it? Thank you.
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Here is some code from the MSDN site

 // Connect to data source
    retcode = SQLConnect(hdbc, (SQLCHAR*) "NorthWind", SQL_NTS, (SQLCHAR*) NULL, 0, NULL, 0);

    // Allocate statement handle
    if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
        retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt); 

       // Process data
       if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
          SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
       }

       SQLDisconnect(hdbc);
    }

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • ToddN2000
    if you are using Unix/Linux check out this link
    125,970 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: