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

    a quest about datagrid

    i have a recordset object and has been open already. if i want to show the data in a mshflexgrid, i can use a line of code like this:
    set mshflexgrid1.recordset=recordset1
    the question is, what should i do if i want to use a datagrid to show the data of the recordset?
    i use set datagrid1.datasource=recordset1,but no use.
    will somebody tell me ? thanks in advance


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: a quest about datagrid

    datagrid. datasource is a database. To put rs to dbgrid, use
    datagrid.recordsource=rs

    Iouri Boutchkine
    iouri@hotsheet.com
    Iouri Boutchkine
    iouri@hotsheet.NOSPAM.com

  3. #3
    Join Date
    Nov 2001
    Posts
    13

    Re: a quest about datagrid

    thanks first of all.
    but I use datagrid ,not dbgrid,
    this of datagrid?


  4. #4
    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    2

    Re: a quest about datagrid

    "Set datagrid.datasource=record1" is what u need to display the data. Check if the recordset is still open.

    Thanks


  5. #5
    Join Date
    Nov 2001
    Posts
    13

    Re: a quest about datagrid

    i 'm sure the recordset is open,
    is there any properties need to be set before show
    data in datagrid? thanks


  6. #6
    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    2

    Re: a quest about datagrid

    as i said the only line of code u need to display the data is setting the data source property of the data grid. You can set other properties like if u wanna allow upadet, addnew ets operations using the grids. Right click on the grid then select properties.


    Thanks


  7. #7
    Join Date
    Nov 2001
    Posts
    13

    Re: a quest about datagrid

    but it sames to be no use. will you please see my code? like this:
    ________________________________________
    Dim C As New ADODB.Command
    Dim rs As New ADODB.Recordset

    On Error Resume Next

    C.ActiveConnection = afxAdoConnection
    C.CommandText = "select * from tblFiles"
    C.CommandType = adCmdText

    afxAdoConnection.Errors.Clear

    rs.Open C

    If afxAdoConnection.Errors.Count > 0 Then
    Write_Error
    Else
    Set gridFiles.datasource = rs
    End If

    ___________________________________
    gridFiles is the name of the datagrid



  8. #8
    Join Date
    Oct 2001
    Posts
    3

    Re: a quest about datagrid

    Please add in the following statement:

    rs.CursorLocation = adUseClient

    then only follow by:

    rs.open c

    Hope it helps.


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