ODBC SQLConnect problem

ODBC SQLConnect problem

Post by Greg Parke » Tue, 10 Feb 1998 04:00:00



Hello,

I am having a problem with Microsoft's ODBC driver for Windows NT.
SQLConnect works fine until I try to debug my application with developer
studio.  While debugging, SQLConnect causes a general protection fault.  I
can't debug my application!!!  I don't know whether this is a bug in
SQLConnect or if I'm just using it incorrectly.

Any help would be appreciated

Thanks

 
 
 

ODBC SQLConnect problem

Post by Ignatius Won » Thu, 12 Feb 1998 04:00:00



>Hello,

>I am having a problem with Microsoft's ODBC driver for Windows NT.
>SQLConnect works fine until I try to debug my application with developer
>studio.  While debugging, SQLConnect causes a general protection fault.  I
>can't debug my application!!!  I don't know whether this is a bug in
>SQLConnect or if I'm just using it incorrectly.

>Any help would be appreciated

>Thanks

ig: Try this simple test:

#include <afx.h>
#include <afxdb.h>
#include <stdio.h>

#define RC_FAILURE(x) ((x) == SQL_ERROR  || \
    (x) == SQL_INVALID_HANDLE)

#define RC_SUCCESS(x) ((x) == SQL_SUCCESS || \
    (x)  == SQL_SUCCESS_WITH_INFO)

// for general exception handling
class clError
   {
public:
   clError(const CString& msg);
   ~clError();

   const CString& get_msg()  const;
   operator const CString&() const;

private:
   CString errMsg_;

private:
   void operator,(const clError&);
   void operator&();
   } ;

int
main(int argc, _TCHAR* argv[])
   {
   _TCHAR* usage = _T("\nUsage: ./program dsn uid <pwd>\n");
   if (argc < 3 || argc > 4)
      {
      _fputts(usage, stderr);
      return 1;
      }

   try
      {
      RETCODE rc;
      HENV    henv;
      HDBC    hdbc;
      HSTMT   hstmt;

      rc = SQLAllocEnv(&henv);
      if (RC_FAILURE(rc))
         throw clError(_T("Error: SQLAllocEnv()"));

      rc = SQLAllocConnect(henv, &hdbc);
      if (RC_FAILURE(rc))
         throw clError(_T("Error: SQLAllocConnect()"));

      rc = SQLConnect(hdbc,
                     (_TUCHAR*)argv[2], SQL_NTS,
                     (_TUCHAR*)argv[3], SQL_NTS,
                     argc == 5 ? (_TUCHAR*)argv[4] : NULL, SQL_NTS);
      if (RC_FAILURE(rc))
         throw clError(_T("Error: SQLConnect()"));

      rc = SQLAllocStmt(hdbc, &hstmt);
      if (RC_FAILURE(rc))
         throw clError(_T("Error: SQLAllocStmt()"));

      _fputts(_T("Successful ODBC Init.\n"), stdout);

      SQLFreeStmt(hstmt, SQL_DROP);
      SQLDisconnect(hdbc);
      SQLFreeConnect(hdbc);
      SQLFreeEnv(henv);
      }
   catch (clError& err)
      {
      _ftprintf(stderr, _T("%s\n"), err.get_msg());
      return 1;
      }

   return 0;
   }

//# ig

 
 
 

1. ODBC SQLConnect problem

Hello,

I am having a problem with Microsoft's ODBC driver for Windows NT.
SQLConnect works fine until I try to debug my application with developer
studio.  While debugging, SQLConnect causes a general protection fault.  I
can't debug my application!!!  I don't know whether this is a bug in
SQLConnect or if I'm just using it incorrectly.

Any help would be appreciated

Thanks

2. Trap ODBC errors?

3. Using PDX against a Server RDBMS (like Oracle)

4. ODBC SQLConnect - unsigned char problems

5. Clustered index creation

6. Win32 ODBC API Question on using SQLConnect() to Personal Oracle8i on Win2000

7. SQL Mail

8. Problems wirh SQLConnect and SQLDriverConnect

9. SQLConnect API Problem - need help BAD!!

10. SQLConnect problem

11. Cli sqlconnect problem