If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > PLz Plz! I need Help with MS FlexGrid in VB 6.0.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-05-09, 03:02
kamleshtcs kamleshtcs is offline
Registered User
 
Join Date: Sep 2009
Posts: 2
Red face PLz Plz! I need Help with MS FlexGrid in VB 6.0.

Hello Everyone,

I am actually new to VB 6.0 programming. In a small project I am trying to show the entire records of a table,located in Oracle database, in a hierarchichal flexgrid.
But when I set the dataSource property of FlexGrid to the Recordset object, I get "Run Time Error 91, Object Variable or With Block Variable not Set."
following is the code in the Load event of the form containing the FlexGrid.

Private Sub Form_Load()
Dim adoConn As New ADODB.Connection
Dim ConnectionString As String
adoConn.CursorLocation = adUseClient
ConnectionString = "Provider=MSDAORA; user id= scott; password= tiger;"
adoConn.Open ConnectionString
Dim adoRecSet As New ADODB.Recordset
adoRecSet.CursorType = adOpenDynamic
adoRecSet.LockType = adLockOptimistic
adoRecSet.Open "employee1", adoConn, , , adCmdTable
Set MSFlexGrid1.DataSource = adoRecSet
End Sub

Any help will be Highly Appreciated..

Thanks a Ton in advance.
Reply With Quote
  #2 (permalink)  
Old 09-09-09, 16:57
brucevde brucevde is offline
Registered User
 
Join Date: Jan 2003
Location: British Columbia
Posts: 44
It looks like you are using the FlexGrid not the Hierarchical FlexGrid.

The FlexGrid cannot be bound directly to an ADO Recordset, it must be bound to an ADO Data Control.

The alternative is to populate the grid using code.

Code:
    adoRecSet.Open "employee1", adoConn, , , adCmdTable
    With MSFlexGrid1
        .Rows = .FixedRows
        .Cols = adoRecSet.Fields.Count + .FixedCols
        
        Do Until adoRecSet.EOF
            .AddItem String$(.FixedCols, vbTab) & adoRecSet.GetString(, 1, , " ")
        Loop
    End With
End Sub
Reply With Quote
  #3 (permalink)  
Old 09-10-09, 01:29
kamleshtcs kamleshtcs is offline
Registered User
 
Join Date: Sep 2009
Posts: 2
Thank you

Thank you very much.

You are right. I was required to use MS hierarchichal FlexGrid. And mistakenly i used MS FlexGrid.
I changed the thing and it worked smoothly.

Thanks a Ton.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On