[unixODBC-dev] SQLDriverConnectW() returns an error !

Anita Dixit anita_dixit at persistent.co.in
Thu Jun 23 06:44:27 BST 2005


I tried using 2.2.11. However the problem doesn't seem to resolve.
Following is the code that I am trying out - 

#include <wstring.h>
#include <sql.h>
#include <sqlext.h>
#include <stdio.h>

int main( ) {

SQLWCHAR connectionInfoBuffer[1024];
SQLHENV henv = NULL;
SQLHDBC hdbc = NULL;
SQLRETURN rc = SQL_SUCCESS;
short buflen;

SQLWCHAR     message[10000] ;
SQLWCHAR     sqlstate[SQL_SQLSTATE_SIZE + 1] ;
SQLINTEGER sqlcode;
int i =0;
SQLSMALLINT length;
SQLWCHAR connStr[1024];

if ((rc = SQLAllocHandle (SQL_HANDLE_ENV, NULL, &henv)) != SQL_SUCCESS) {
        printf("\nError: SQL_HANDLE_ENV"); exit(0);
}

if ((rc =  SQLSetEnvAttr (henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)
SQL_OV_ODBC3, SQL_IS_UINTEGER)) != SQL_SUCCE
SS) {
        printf("Error: SQLSetEnvAttr"); exit(0);
}

if ((rc = SQLAllocHandle (SQL_HANDLE_DBC, henv, &hdbc)) != SQL_SUCCESS) {
        printf("\nError: SQL_HANDLE_DBC"); exit(0);
}

memset( connectionInfoBuffer, 0, 1024);
wstrcpy(connStr,L"DSN=MyDriver;Database=QA");

rc = SQLDriverConnectW (hdbc,
                0,
                connStr,
                SQL_NTS,
                connectionInfoBuffer,
                sizeof (connectionInfoBuffer),
                &buflen,
                SQL_DRIVER_COMPLETE);
printf("DriverConnectW - rc = <%d>\n", rc);

if ( rc != SQL_SUCCESS )
{
                i=0;
                printf("\nError: Driver ConnectW");
                while ( SQLGetDiagRecW( SQL_HANDLE_DBC, hdbc, i, sqlstate,
&sqlcode, message, 10000, &length) !=
 SQL_NO_DATA ) {
                      printf( "SQLSTATE          = <%s>\n", sqlstate ) ;
                      printf( "Native Error Code = <%ld>\n", sqlcode ) ;
                      printf( "Message = <%s>", message ) ;
                      printf("\nLegth is <%d>\n",length);
                      i++ ;
                }
                exit(1);
}
printf("\nDriverConnect SUCCESS\n");
}

All the initial ODBC APIs get executed successfully except
SQLDriverConnectW.
The connection string used is ASCII.
$ODBCINI contains appropriate entry of 'MyDriver' DSN.
The error that is returned is 

[unixODBC][Driver Manager]Data source name not found, and no default driver
specified. - IM002

Unicodetoansi() function in UnixODBC returns NULL ANSI string.

-Anita



-----Original Message-----
From: unixodbc-dev-bounces at easysoft.com
[mailto:unixodbc-dev-bounces at easysoft.com] On Behalf Of Nick Gorham
Sent: Wednesday, June 22, 2005 8:44 PM
To: Development issues and topics for unixODBC
Subject: Re: [unixODBC-dev] SQLDriverConnectW() returns an error !

Anita Dixit wrote:
> Hi,
> 
>  
> 
> I am trying to use unixODBC v2.2.8 on Solaris 8.
> 
> I have installed patch 113261-02 as mentioned in README.SOLARIS.

Have you tried using 2.2.11?

Have you a short code sample that shows the problem?

Are you using 2 byte unicode in the app?

-- 
Nick
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev at easysoft.com
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev

======================================================================================================== 

This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful.

Warning: Although Persistent Systems Pvt. Ltd. has taken reasonable precautions to ensure no viruses are present in this email; the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments.
========================================================================================================



More information about the unixODBC-dev mailing list