Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Connection handle is invalid

1,366 views
Skip to first unread message

cj2

unread,
Aug 1, 2008, 11:32:31 AM8/1/08
to
I'm getting the error:

Unhandled Structured Exception.
ErrorNo: 1466
Message: Connection handle is invalid.
UserValue:

Cancel Ignore Help

I'm sure it has to do with code I just put in to check a sql database
for a flag field and if it's false set another to true etc. What do you
think I missed--closing a connecting before opening it or ???

Dan Freeman

unread,
Aug 1, 2008, 11:49:18 AM8/1/08
to
Without more information, nobody can even guess.

Have you tried trapping the error and checking the array created by
AError()?

Dan

Olaf Doschke

unread,
Aug 1, 2008, 1:11:38 PM8/1/08
to
> Message: Connection handle is invalid.

>What do you think I missed--closing a connecting before opening it or ???

the connection handle you use isn't valid.
Most probably the connection failed
or is broken in the moment you sent
your query.

Bye, Olaf.


cj2

unread,
Aug 1, 2008, 5:19:01 PM8/1/08
to
I think your right. I've been doing some research and it seems a lot of
times it does not connect on the first attempt. I've added code to
retry making the connection 10 times and handle it differently if it
doesn't work. I had everything in a try catch block but it appears that
will not catch this error.

Thanks,
cj

Mark Burgum

unread,
Aug 4, 2008, 3:17:50 AM8/4/08
to
The try catch block needs a catch to handle the specific problem that you
encountered, The error you are getting means it got through to the endtry
but had an error, which gets reported as an 'unhandled exception error' i.e
an error that you have not got code in to handle!


"cj2" <c...@nospam.nospam> wrote in message
news:usDy4wB9...@TK2MSFTNGP05.phx.gbl...

Olaf Doschke

unread,
Aug 4, 2008, 4:37:48 AM8/4/08
to
> The try catch block needs a catch to handle the specific problem that you
> encountered, The error you are getting means it got through to the endtry
> but had an error, which gets reported as an 'unhandled exception error'
> i.e an error that you have not got code in to handle!

The reason a TRY CATCH doesn't work with SQLCONNECT() and
a failing connection is, that this does not raise an error, but SQLCONNECT()
simply returns -1 as "the handle", which is an invalid connection handle.

Bye, Olaf.


Gianni Turri

unread,
Aug 4, 2008, 9:48:30 AM8/4/08
to

When SQLCONNECT() returns -1 you can anyway call AERROR(MyErrorArray)
to obtain detailed information about the ODBC error.

Take a look at AERROR() in VFP help.

--
Gianni

Olaf Doschke

unread,
Aug 4, 2008, 10:59:13 AM8/4/08
to
> When SQLCONNECT() returns -1 you can anyway call AERROR(MyErrorArray)
> to obtain detailed information about the ODBC error.
>
> Take a look at AERROR() in VFP help.

True, it's one of the cases AERROR() gives
further info although there was no vfp system
error, but the error was eg at the remote+
database.

Other situations are, when TABLEUPDATE()
returns .F., SQLEXEC() returns -1 and also after
eg a CursorAdapter.CursorFill() returns .F.

For example the topic on CursorFill states:

To retrieve error information when CursorFill returns
False (.F.), you must call the AERROR( ) Function
function because Visual Foxpro error handling, such
as the ON ERROR command, Error event, and
TRY...CATCH...FINALLY command, does not
capture this error information.

Bye, Olaf.


cj2

unread,
Aug 11, 2008, 4:59:24 PM8/11/08
to
The looping I implemented is based on sqlconnect's return value.

Thanks.

0 new messages