Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bind CursorAdapter to a grid problem
Message
From
20/11/2004 12:05:20
 
 
To
19/11/2004 23:58:22
Thomas Wang
Cts Int'l Transportation Co., Ltd.
Shanghai, China
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00963152
Message ID:
00963213
Views:
9
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform