[unixODBC][Driver Manager]Function sequence error

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[unixODBC][Driver Manager]Function sequence error

Volker Wysk

Hello!

 

I'm new to ODBC, and I get an error in a very minimalistic program. It just tries to connect to and disconnect from the database, and doesn't do anything. Here is what it does, error handling left out:

 

SQLHENV hEnv = 0;

SQLHDBC hDbc = 0;

 

SQLAllocEnv(&hEnv);

SQLAllocConnect(hEnv, &hDbc);

SQLConnect(hDbc,

(SQLCHAR*) "test", 4,

(SQLCHAR*) "", 0,

(SQLCHAR*) "", 0);

SQLFreeHandle(SQL_HANDLE_DBC, hDbc); /* error here */

SQLFreeEnv(hEnv);

 

I've attached the full program (named odbc.cpp) to this message. The error can be reproduced easily. Type this to compile it:

 

gcc -o odbc odbc.cpp -lodbc -lsqlite3 -lstdc++

 

The call to SQLFreeHandle fails. Running the program produces the following error message:

 

Can't free connection handle.

ret = -1

SQL error message: [unixODBC][Driver Manager]Function sequence error

SQL_ERROR

 

If anyone has an idea, what a "Function sequence error" is, then please post it.

 

Thanks,

Volker


_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mailman.unixodbc.org/mailman/listinfo/unixodbc-support

odbc.cpp (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [unixODBC][Driver Manager]Function sequence error

Nick Gorham-2
On 15/09/13 15:15, Volker Wysk wrote:

Hello!

 

I'm new to ODBC, and I get an error in a very minimalistic program. It just tries to connect to and disconnect from the database, and doesn't do anything. Here is what it does, error handling left out:


Its because you have tried to free a handle while its still connected. The sequence error is telling you just that, the calls have to be made in the correct order. You need a

SQLDisconnect( hDbc );

Before the SQLFreeHandle( HDBC );

--
Nick

_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mailman.unixodbc.org/mailman/listinfo/unixodbc-support
Reply | Threaded
Open this post in threaded view
|

Re: [unixODBC][Driver Manager]Function sequence error

Volker Wysk

Am Sonntag, 15. September 2013, 18:07:09 schrieb Nick Gorham:

> On 15/09/13 15:15, Volker Wysk wrote:

> > Hello!

> >

> > I'm new to ODBC, and I get an error in a very minimalistic program. It

> > just tries to connect to and disconnect from the database, and doesn't

>

> > do anything. Here is what it does, error handling left out:

> Its because you have tried to free a handle while its still connected.

> The sequence error is telling you just that, the calls have to be made

> in the correct order. You need a

>

> SQLDisconnect( hDbc );

>

> Before the SQLFreeHandle( HDBC );

 

Okay, many thanks!

 

Seems like I overlooked the SQLDisconnect call in the sample programs which I've studied.

 

Happy Hacking,

Volker


_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mailman.unixodbc.org/mailman/listinfo/unixodbc-support