Link to home
Start Free TrialLog in
Avatar of Jeanette Durham
Jeanette DurhamFlag for United States of America

asked on

vb6 datagrid "Cannot initialize data bindings"

Dear Experts,

Ok, I've got this program wherein I wanted to show a table in a datagrid, so I thought alright, I will add the Microsoft DataGrid Control 6.0 and off we'd go. But when I try to bind a recordset to it I get the error "Cannot initialize data bindings".

So, I realized that I've got newer dlls than the ones that came with vb6 and I'm thinking it's probably a library issue. I've read some posts and it was recommended that I try registering these dlls msbind.dll, msdatgrd.ocx,
MSSTDFMT.DLL to fix it. So I did that to no avail.

Then I edited my .vbp file and removed the reference to the datagrid component and hit the browse and tried to load up the one in my system32 folder. I still got the error after that. So then I tried replacing all those files with msbind.dep, msbind.dll, msdatgrd.dep, msdatgrd.oca, msdatgrd.ocx, msdatgrd.srg, mstdfmt.dep and msstdfmt.dll. I pulled these off a different computer. Then I registered the msdatgrd.ocs and the msstdfmt.dll. That didn't work either (same error).

So then I tried pulling the msstdfmt.dll out of the folder which has my vb6 install and registering that. That didn't work either.

So because I'd replaced a whole bunch of dlls with bad ones (apparently) I uninstalled windows xp service pack 3 and reinstalled it. So now I'm back to where I started. What I need to do is figure out what I /really/ need to do to make this work.

I would like to use the newest libraries and controls in my program anyways, I just can't get them to work. I think what I need to do is find all the same versions of whatever dlls and files are relevant to the datagrid control and put them in the system32 folder or something. Truthfully I don't really know the right approach to fix this. But basically, even on my development computer, my datagrid isn't working, so I don't really have the right files to begin with (I guess..)

Anybody know the way to do this right so I can use the newest datagrid in my vb6 program?

Thanks! ~Michael

Also please lemme know what other information I can provide to make this question easy to answer.
Private Sub BindData(ByVal tblName$)
    Dim myQry$
    myQry = "Select * From [" & tblName & "];"
    Set myRS = New ADODB.Recordset
    myRS.Open myQry, myDB.myConnection, adOpenStatic, adLockReadOnly
    Set Me.myDataGrid.DataSource = myRS
    Me.myDataGrid.ReBind
    Me.myDataGrid.Refresh
End Sub

Open in new window

Avatar of game-master
game-master
Flag of Philippines image



remove Me.myDataGrid.ReBind code...

this code will do the binding already...

Set Me.myDataGrid.DataSource = myRS
Me.myDataGrid.Refresh


game-master
Avatar of Jeanette Durham

ASKER

game-master:

Ok I tried that (the idea sounded pretty easy) but the datagrid just stayed blank.. Looks like I'm using Microsoft DataGrid Control 6.0, and if you check the .vbp I stuck the controls/libraries referenced in the code snippet box below.. do you think I messed up my libraries somehow trying to manipulate them all into working?

Michael

Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\stdole2.tlb#OLE Automation
Reference=*\G{2A75196C-D9EB-4129-B803-931327F72D5C}#2.8#0#C:\Program Files\Common Files\System\ado\msado15.dll#Microsoft ActiveX Data Objects 2.8 Library
Reference=*\G{420B2830-E718-11CF-893D-00A0C9054228}#1.0#0#C:\WINDOWS\system32\scrrun.dll#Microsoft Scripting Runtime
Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; MSCOMCTL.OCX
Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0; COMDLG32.OCX
Form=Main.frm
Module=myDB; myDB.bas
Form=ViewData.frm
Object={CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0; MSDATGRD.OCX
 
'Code which binds the data (updated to remove the .rebind)
'########## BIND DATA
 
Private Sub BindData(ByVal tblName$)
    Dim myQry$
    myQry = "Select * From [" & tblName & "];"
    Set myRS = New ADODB.Recordset
    myRS.Open myQry, myDB.myConnection, adOpenStatic, adLockReadOnly
    Set Me.myDataGrid.DataSource = myRS
    Me.myDataGrid.Refresh
End Sub

Open in new window

SOLUTION
Avatar of game-master
game-master
Flag of Philippines image

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
game-master:

the $ sign is a compiler recognized substitute for 'string'. It's the only one I really use but there are others, I've also seen people use %, it's some kind of number, just can't remember if it's integer/long/or double.. :) It's kinda nice to make your function definitions more readable when you are passing a bunch of variables. But I did try switching it to your code. No change.

I repaired the vb6 installation but that didn't seem to fix it, and tried downloading the vb6 runtime files.

You know what I noticed, using the locals window.. the datagrid control's .datasource is not initialized (it says 'No variables) after I assign the recordset to it. So, I'm thinking because that property didn't set for whatever reason that must be why it shows no data. I'm going to try tricking it next using an adodc control, and maybe since it's bound differently it will succeed..

Michael
ASKER CERTIFIED SOLUTION
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


good morning!

i was out in the office earlier yesterday so i cannot
give u some support or answer ur follow up question...


but, nevertheless im glad u have found the solution...


The strong by scattering their energies, accomplish nothing.
The weak, by concentrating on one thing, build big business.


game-master