Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Connection handle is invalid
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01558490
Message ID:
01558555
Vues:
38
>>Hi,
>>
>>I have a situation when on the TableUpdate() I get error "Connection handle is invalid." And the same program but with a different database, in the same place, does not work without error. The VFP application is using CursorAdapter to update SQL Server database. Can this type of problem be caused by some difference in the database table? Or what can I check in the debugger prior to calling TableUpdate() that would give a clue is where the problem may be?
>>TIA.
>
>I have founded what causes this problem and before I change the entire design of this part of the program I would like to know if there is a simpler solution. Here is what caused the problem:
>
>What happens is if you Attach an alias (cursor) to a CursorAdapter object that didn’t create this alias (cursor) in the first place, the TableUpdate() fails. That is, there is apparently some handle that VFP sets to the alias (cursor) created by CursorAdapter and this handle is stored in both the CursorAdapter object and in the alias (cursor). When you attach this cursor to a different CursorAdapter object and even though the CursorStatus of the object changes to 2 (meaning CursorAdapter alieas is attached via the CursorAttach method) the TableUpdate() failes.
>
>My question is, do you know what this “handle” is and how to update it when you attach an alias (cursor) to CursorAdapter object?

Solution! I just wanted to share what the solution to the above problem turned out to be. The function CursorAttach() has second parameter which according to VFP help is:
lInheritCursorProperties
Specifies whether you wish to keep or discard the properties of the cursor or table being attached. The following table lists the possible values for lInheritCursorProperties.

lInheritCursorProperties  Description  
True (.T.)
 Existing properties set for the cursor are inherited by the corresponding properties of the CursorAdapter object.
 
False (.F.) or empty
 Existing properties set for the cursor are not copied into the corresponding properties of the CursorAdapter object.

This option adds flexibility when you are attaching a SQL Pass-Through, Remote View, or other cursor. 
Once I set this parameter in my code to .T., all works. Now to the next fire <g>.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform