Link to home
Start Free TrialLog in
Avatar of jack208
jack208

asked on

VB6, ADO, MSDataGrid and Data Environment

I used VB6, ADO and Data environment and I've the following codes in my program:

FORM_LOAD
envApplication.comCustomerList
Set grdMain.DataSource = envApplication
grdMain.DataMember = "comCustomerList"

where      env = Data Environment
  grd = MS Data Grid ver 6
  com = Data Env Command objects

IT works fine and correctly populates my datagrid with the relevant list of records from the customer table. Now I'd like to have a REFRESH button that requeries the underlying recordset and updates the datagrid.

My code looks like this:

CMDREFRESH_CLICK
envApplication.rscomCustomerList.close      'closes the recordset
envApplication.comCustomerList                  'reopens it
grdMain.DataMember = "comCustomerList"      rebind to datagrid

Many people I asked had told me this code should work. My problem is that the program crashes at the last line (grdMain.DataMember = "comCustomerList") with fatal error on MSDATGRD.OCX or sometimes MSADO15.DLL

An alternative code will be:

CMDREFRESH_CLICK
envApplication.rscomCustomerList.Requery

In this case, it'll crash right away!! Someone even send me his working program using the same codes, but I still get the same errors running it on my PC. Which brings me to suspect that the problem may not be in the "codes" but is in the system files (OCXs or DLLs) in my computer's configuration, or even a bug in the DataGrid itself. Has anyone faced similar problems?

Thanks and Merry Christmas.

ASKER CERTIFIED SOLUTION
Avatar of resin
resin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial