CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2001
    Posts
    9

    MSHFlexGrid with ADO Recordsets = A problem for me

    Ok, what I'm trying to do is bind a MSHFlexgrid control to an ADO Recordset. Everythings fine, the connection is there...but why does it only return one row from the recordset object when there are many rows????
    Is there a property i need to set in the Flexgrid control??

    Heres my sample code


    Private Sub Command1_Click()
    Dim db As ADODB.Connection
    Dim c As ADODB.Command
    Dim rs As ADODB.Recordset



    Set db = New ADODB.Connection
    db.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Downloads\Project\Database\HOFAS.mdb;Persist Security Info=False"
    db.Open

    Set c = New ADODB.Command
    c.ActiveConnection = db
    c.CommandType = adCmdText
    c.CommandText = "Select * from Guest"

    Set rs = New ADODB.Recordset
    Set rs = c.Execute


    Set MSHFlexGrid1.DataSource = rs
    -------------------------------------------------

    To sum it all up....the Guest table has many records, but only one record is displayed in the MSHFlexGrid...




  2. #2
    Join Date
    Sep 2001
    Location
    IL, USA
    Posts
    1,090

    Re: MSHFlexGrid with ADO Recordsets = A problem for me

    The recordset you create by executing the Sql statement is readonly, forward-type cursor recordset. you can replace the code lines involving the Command object by the following:set rs = new ADODB.Recordset
    rs.Open "select * from Guest", db, adOpenStatic, adLockOptimistic, adCmdText


    and you should see the grid populated.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured