SQLDriverConnectW() returns an error !

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

SQLDriverConnectW() returns an error !

Anita Dixit

Hi,

 

I am trying to use unixODBC v2.2.8 on Solaris 8.

I have installed patch 113261-02 as mentioned in README.SOLARIS.

If I try to use SQLDriverConnectW function, I get an error saying, “[unixODBC][Driver Manager]Data source name not found, and no default driver specified”

A little debugging shows that the function  “__parse_connection_string_w” doesn’t parse incoming connection string appropriately as “unicode_to_ansi_copy” gives NULL ANSI string.

 

If you have any idea in this regard, please help.

 

 

Thanks and Regards,

Anita

 

 


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

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.
========================================================================================================
_______________________________________________
unixODBC-dev mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SQLDriverConnectW() returns an error !

Nick Gorham-2
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
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: SQLDriverConnectW() returns an error !

Anita Dixit
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: [hidden email]
[mailto:[hidden email]] 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
[hidden email]
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.
========================================================================================================
_______________________________________________
unixODBC-dev mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SQLDriverConnectW() returns an error !

Nick Gorham
Anita Dixit wrote:

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

I am not sure what wstrcpy you are using, but

L"DSN=MyDriver;Database=QA"

will create a array of 4 byte characters. unixODBC by default, will use the 2 byte UNICODE as odbc does on windows, so you could try something like

void wstrconvert( SQLWCHAR *out, char *in ) {
        while( *in ) {
                *out++ = *in++;
        }
        *out = 0;
}

...

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


And a further problem, you call

SQLGetDiagRecW( SQL_HANDLE_DBC, hdbc, i, sqlstate,
&sqlcode, message, 10000, &length)

but then call

printf( "SQLSTATE          = <%s>\n", sqlstate ) ;

Again, sqlstate and message will be a two byte UNICODE string.

--
Nick Gorham
Easysoft Limited
_______________________________________________
unixODBC-dev mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: SQLDriverConnectW() returns an error !

Anita Dixit
Hi Nick,

Thanks for the prompt reply!
If I input the connection string as per below mentioned method, the program
indeed proceeds. However, now there is a bus error during the execution of
the same API - SQLDriverConnectW.

Stack frames show that unixODBC SQLDriverConnectW API calls the driver's
SQLDriverConnectW. This in turn calls the driver's own function but the
program fails for wcslen() function.

Do you think if anything is further missing in the sample program?

Thanks again.

Regards,
Anita







-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Nick Gorham
Sent: Thursday, June 23, 2005 2:16 PM
To: Development issues and topics for unixODBC
Subject: Re: [unixODBC-dev] SQLDriverConnectW() returns an error !

Anita Dixit wrote:

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

I am not sure what wstrcpy you are using, but

L"DSN=MyDriver;Database=QA"

will create a array of 4 byte characters. unixODBC by default, will use the
2 byte UNICODE as odbc does on windows, so you could try something like

void wstrconvert( SQLWCHAR *out, char *in ) {
        while( *in ) {
                *out++ = *in++;
        }
        *out = 0;
}

...

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


And a further problem, you call

SQLGetDiagRecW( SQL_HANDLE_DBC, hdbc, i, sqlstate,
&sqlcode, message, 10000, &length)

but then call

printf( "SQLSTATE          = <%s>\n", sqlstate ) ;

Again, sqlstate and message will be a two byte UNICODE string.

--
Nick Gorham
Easysoft Limited
_______________________________________________
unixODBC-dev mailing list
[hidden email]
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.
========================================================================================================
_______________________________________________
unixODBC-dev mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SQLDriverConnectW() returns an error !

Nick Gorham-2
Anita Dixit wrote:

> Hi Nick,
>
> Thanks for the prompt reply!
> If I input the connection string as per below mentioned method, the program
> indeed proceeds. However, now there is a bus error during the execution of
> the same API - SQLDriverConnectW.
>
> Stack frames show that unixODBC SQLDriverConnectW API calls the driver's
> SQLDriverConnectW. This in turn calls the driver's own function but the
> program fails for wcslen() function.
>
> Do you think if anything is further missing in the sample program?
>
> Thanks again.
>
> Regards,
> Anita

It may be that the driver (you didn't say which one) is expecting 4 byte
unicode. in which case recompile unixODBC with SQL_WCHART_CONVERT defined.

--
Nick Gorham
Easysoft Limited
_______________________________________________
unixODBC-dev mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: SQLDriverConnectW() returns an error !

Anita Dixit
Thanks for the input, Nick!
That was helpful indeed! I wondered if this is documented anywhere.
As I am getting bus error for wcslen(), I presume the driver is expecting 4
byte Unicode.
If I compile unixODBC with SQL_WCHART_CONVERT defined, I wonder mapping of
char to wchar which you mentioned in the earlier mail will not do the task.
What conversion method should be used in that case so as to provide
appropriate SQLWCHAR data to SQLDriverConnectW function ?

Thanks very much.

Regards,
Anita



-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Nick Gorham
Sent: Thursday, June 23, 2005 4:09 PM
To: Development issues and topics for unixODBC
Subject: Re: [unixODBC-dev] SQLDriverConnectW() returns an error !

Anita Dixit wrote:
> Hi Nick,
>
> Thanks for the prompt reply!
> If I input the connection string as per below mentioned method, the
program

> indeed proceeds. However, now there is a bus error during the execution of
> the same API - SQLDriverConnectW.
>
> Stack frames show that unixODBC SQLDriverConnectW API calls the driver's
> SQLDriverConnectW. This in turn calls the driver's own function but the
> program fails for wcslen() function.
>
> Do you think if anything is further missing in the sample program?
>
> Thanks again.
>
> Regards,
> Anita

It may be that the driver (you didn't say which one) is expecting 4 byte
unicode. in which case recompile unixODBC with SQL_WCHART_CONVERT defined.

--
Nick Gorham
Easysoft Limited
_______________________________________________
unixODBC-dev mailing list
[hidden email]
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.
========================================================================================================
_______________________________________________
unixODBC-dev mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SQLDriverConnectW() returns an error !

Nick Gorham
Anita Dixit wrote:

>Thanks for the input, Nick!
>That was helpful indeed! I wondered if this is documented anywhere.
>As I am getting bus error for wcslen(), I presume the driver is expecting 4
>byte Unicode.
>If I compile unixODBC with SQL_WCHART_CONVERT defined, I wonder mapping of
>char to wchar which you mentioned in the earlier mail will not do the task.
>What conversion method should be used in that case so as to provide
>appropriate SQLWCHAR data to SQLDriverConnectW function ?
>  
>

compile with

SQL_WCHART_CONVERT

and your original code should work.

--
Nick

_______________________________________________
unixODBC-dev mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: SQLDriverConnectW() returns an error !

Anita Dixit
Nick,

I compiled the code with SQL_WCHART_CONVERT. However, with the original
code, problem remains the same. i.e. flow passes to Driver's
SQLDriverConnectW function and a bus error occurs for wcslen().
I was wondering if sizeof(SQLWCHAR) would give 4 bytes on defining
SQL_WCHART_CONVERT. It gives me 2 bytes as the size.

-Anita

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Nick Gorham
Sent: Thursday, June 23, 2005 8:16 PM
To: Development issues and topics for unixODBC
Subject: Re: [unixODBC-dev] SQLDriverConnectW() returns an error !

Anita Dixit wrote:

>Thanks for the input, Nick!
>That was helpful indeed! I wondered if this is documented anywhere.
>As I am getting bus error for wcslen(), I presume the driver is expecting 4
>byte Unicode.
>If I compile unixODBC with SQL_WCHART_CONVERT defined, I wonder mapping of
>char to wchar which you mentioned in the earlier mail will not do the task.
>What conversion method should be used in that case so as to provide
>appropriate SQLWCHAR data to SQLDriverConnectW function ?
>  
>

compile with

SQL_WCHART_CONVERT

and your original code should work.

--
Nick

_______________________________________________
unixODBC-dev mailing list
[hidden email]
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.
========================================================================================================
_______________________________________________
unixODBC-dev mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: SQLDriverConnectW() returns an error !

ZIGLIO, Frediano, VF-IT
In reply to this post by Anita Dixit
>
> Nick,
>
> I compiled the code with SQL_WCHART_CONVERT. However, with
> the original
> code, problem remains the same. i.e. flow passes to Driver's
> SQLDriverConnectW function and a bus error occurs for wcslen().
> I was wondering if sizeof(SQLWCHAR) would give 4 bytes on defining
> SQL_WCHART_CONVERT. It gives me 2 bytes as the size.
>
> -Anita
>

You have to define SQL_WCHART_CONVERT in your code too before including
sql.h.

freddy77

_______________________________________________
unixODBC-dev mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
Loading...