Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grids and SQL Server
Message
De
08/05/2007 14:58:06
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01223538
Message ID:
01223545
Vues:
16
>>>I'm running into a weird issue and I just can't seem to track it down.
>>>
>>>I've got a form with two grids on it. In the Load() event of the form, I instanciate an object which connects to SQL Server, and pulls down two different cursors. One grid shows the parent records, the other grid shows the children for the selected parent. In the AfterRowColChange event, I refresh the child cursor from SQL server. As expected, this blows away the RecordSource of the child grid.
>>>
>>>I've got two methods in my grid classes to save/restore this info to handle this issue, and I usually have code that looks like this:
>>>
>>>
>>>ThisForm.grdDetail.SaveSource()
>>>
>>>ThisForm.oBizObj.GetDetail()
>>>
>>>ThisForm.grdDetail.RestoreSource()
>>>
>>>
>>>However, in this case, as soon as the SQLEXEC is run in the GetDetail() method (well, in my SQL object called by this method), it blows away the RecordSource for the Parent grid. If I check the code, it's definitely only refreshing the detail cursor. If I check the records in the parent cursor, they're still all there (so this cursor isn't getting closed).
>>>
>>>I created a simple form to see if I could reproduce the problem w/the base classes. I thought it may have something to do with the length of the cursor name, so I shortened it up to under 10 characters. It suddenly started working. So I changed it back to the longer name. It still works. I tried the same on my real form w/no luck.
>>>
>>>I've tried a default datasession vs a private datasession form, w/no difference. I can run each form back to back, one will work, the other will fail (I'd think if it were environment settings it would show up here).
>>>
>>>I created a
>>>
>>>BTW - I'm just using the terms parent/child to make this a bit easier to understand. There isn't any relationship set-up in the grid or via SET RELATION.
>>>
>>>Any thoughts or ideas?
>>
>>You could use different cursors (could be the same structure): one as grid's recordosurce, another to accept data from the server; and you have a form's method where you refill the recordsource:
>>
>>set safety off
>>zap in gridalias
>>set safety on
>>insert into gridalias select * from sqlalias
>>thisform.mygrid.setfocus
>>
>
>I thought for a moment you're going to discuss the root of the problem rather than suggesting this simple well-known workaround.
>
>May I put a smile here? Because I'm smiling.

I don't quite see what is 'the root' here.
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform