file DSN with ODBC-Admin? 
Author Message
 file DSN with ODBC-Admin?

Hello.

Right now I use a user data source which was defined with the ODBC
Admin. My app uses this data , which is connected to an access data
base.
Code at the end.
Now I want to access this file via the network. Seems to me, I have to
define a new file DSN with ODBC-Admin. This works, but the SQLConnect
statement returns:

Error IM002: Cannot find Data source and no default driver.

And, when I check the ODBC.ini file there is no entry for the new file
DSN.

What am I doing wrong?

Any help is appreciated.

Andreas

////////////////header file
#define szDSN "db4" // Datenquellen Name
#define cbDSN (sizeof(szDSN)-1) // Laenge vom Datenquellennamen
#define SQLTRY(x,y) \
 { \
  rc = y; \
  if (rc != SQL_SUCCESS) \
  { \
   char szState[6]; \
   char szMsg[255]; \
   SDWORD sdwNative; \
   SWORD swMsgLen; \
   SQLError(hEnv, hDBC, hStmt, (UCHAR*)szState, &sdwNative, \
    (UCHAR*)szMsg, sizeof(szMsg), &swMsgLen); \
   CString text; \
   text.Format("Error %d performing %s\nSQLState = %s\n" \
    "SQL message = %s\n", rc, x, szState, szMsg); \
   AfxMessageBox(text); \
   goto Terminate; \
  } \
 }

////////////// source file
 SQLTRY("SQLAllocEnv", SQLAllocEnv(&hEnv))
 SQLTRY("SQLAllocConnect", SQLAllocConnect(hEnv, &hDBC))
 SQLTRY("SQLConnect", SQLConnect(hDBC, (unsigned char*)szDSN, cbDSN,
  (unsigned char*)"", SQL_NTS, (unsigned char*)"", SQL_NTS))
 SQLTRY("SQLAllocStmt", SQLAllocStmt(hDBC, &hStmt))
 return TRUE;

Terminate:
 return FALSE;



Sun, 26 Nov 2000 03:00:00 GMT  
 file DSN with ODBC-Admin?

First copy the database and executable to the new
computer, and see if it works locally. Have you
installed ODBC and MSAccess in that computer? All
DLL:s must be in the path.

When it works locally, just use ODBC-admin to change
only the path to the database file.

/Glenn

Quote:

> Hello.

> Right now I use a user data source which was defined with the ODBC
> Admin. My app uses this data , which is connected to an access data
> base.
> Code at the end.
> Now I want to access this file via the network. Seems to me, I have to
> define a new file DSN with ODBC-Admin. This works, but the SQLConnect
> statement returns:

> Error IM002: Cannot find Data source and no default driver.

> And, when I check the ODBC.ini file there is no entry for the new file
> DSN.

> What am I doing wrong?

> Any help is appreciated.

> Andreas

> ////////////////header file
> #define szDSN "db4" // Datenquellen Name
> #define cbDSN (sizeof(szDSN)-1) // Laenge vom Datenquellennamen
> #define SQLTRY(x,y) \
>  { \
>   rc = y; \
>   if (rc != SQL_SUCCESS) \
>   { \
>    char szState[6]; \
>    char szMsg[255]; \
>    SDWORD sdwNative; \
>    SWORD swMsgLen; \
>    SQLError(hEnv, hDBC, hStmt, (UCHAR*)szState, &sdwNative, \
>     (UCHAR*)szMsg, sizeof(szMsg), &swMsgLen); \
>    CString text; \
>    text.Format("Error %d performing %s\nSQLState = %s\n" \
>     "SQL message = %s\n", rc, x, szState, szMsg); \
>    AfxMessageBox(text); \
>    goto Terminate; \
>   } \
>  }

> ////////////// source file
>  SQLTRY("SQLAllocEnv", SQLAllocEnv(&hEnv))
>  SQLTRY("SQLAllocConnect", SQLAllocConnect(hEnv, &hDBC))
>  SQLTRY("SQLConnect", SQLConnect(hDBC, (unsigned char*)szDSN, cbDSN,
>   (unsigned char*)"", SQL_NTS, (unsigned char*)"", SQL_NTS))
>  SQLTRY("SQLAllocStmt", SQLAllocStmt(hDBC, &hStmt))
>  return TRUE;

> Terminate:
>  return FALSE;



Mon, 27 Nov 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. User DSN vs Sys DSN vs File DSN.

2. Connecting to an MDB file thru ODBC *without* using DSN

3. ODBC & File DSN

4. VC++ ODBC,DSN support for Foxpro Files

5. ODBC and File DSN

6. Unable to open ODBC file dsn using OpenEx method

7. Connecting to an MDB file thru ODBC *without* using DSN

8. ODBC-Admin

9. Function for selecting data sources from ODBC ADmin

10. ODBC Admin Setup program help

11. how to register new DSN in ODBC Adminstrator ( using C# )

12. I wish to add a DSN to my 32-bit ODBC List Programmatically

 

 
Powered by phpBB® Forum Software