Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bind CursorAdapter to a grid problem
Message
De
20/11/2004 12:05:20
 
 
À
19/11/2004 23:58:22
Thomas Wang
Cts Int'l Transportation Co., Ltd.
Shanghai, Chine
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
00963152
Message ID:
00963213
Vues:
8
Hello,

i see serveral problem areas in your code

1. your code would recreate a connection to the SQL Server everytime the button will be hit .. (and the old connection will be leaked)

2. the cursoradapter object you create is LOCAL to the Click method
that means that it is automatically destroyed when the method finishes ..
and that will close the cursor 'Customers' too

3. setting THISFORM.BindControls to .T. is only needed once ..

4. you don't bind the Column's of the grid ..
e.g. THISFORM.grdCustomers.Column1.Controlsource = 'customers.CustomerID'


some ideas to resolve these issues:
-store the Cursoradapter object reference into a Form Property ..
-create the Cursoradapter object and it's connection in the Init Event of the Form, also after refreshing it the first time there set BindControls to .T.
-make the correct grid bindings directly in the Form Designer .. it is no real advantage to write it in code ..
-close SQL connection and destroy cursoradapter object in Form Destroy Event


Regards

Christian
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform