CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Data Grid

  1. #1
    Guest

    Data Grid

    I'm trying to code a DataGrid, but I don't want to have to include an ADO Data Control. So far, none of the many controls I have used in this project are data bound, and I don't want to break precident. The MSDN Library is quite vague with regards to this control, but does say the following:

    "The data-aware DataGrid control appears similar to the Grid control; however, you can set the DataGrid control's DataSource property to a Data control so that the control is automatically filled and its column headers set automatically from a Data control's Recordset object. The DataGrid control is really a fixed collection of columns, each with an indeterminate number of rows."

    I, for the life of me, can not get the grid to recognize my recordset object with the folowing code:


    public cnnPMIS as ADODB.Connection
    public cmdSQL as ADODB.Command
    public rstDATA as ADODB.Recordset
    public strConnect as string

    'Connect to database
    strConnect = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=false;" _
    & "Data Source=D:\VB_Projects\PMIS\PMIS.mdb"
    set cnnPMIS = new ADODB.Connection
    cnnPMIS.Open strConnect

    'Create command
    set cmdSQL = new ADODB.Command
    set cmdSQL.ActiveConnection = cnnPMIS

    'Create recordset
    set rstDATA = new ADODB.Recordset
    rstDATA.CursorType = adOpenKeyset
    rstDATA.LockType = adLockOptimistic

    'Create SQL command
    cmdSQL.CommandText = "SELECT * FROM Track WHERE TrkRecID = " _
    & lngRecID

    'Open recordset
    rstDATA.Open cmdSQL




    Any help would be appreciated.

    CFGH


  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Data Grid

    Lothar Haensler (from this forum) has an article on the CodeGuru VB site that shows how to use the DataGrid with just a simple disconnected recordset - although you can obviously use any old recordset (not just from the datacontrol) with this code.

    Checkout : http://codeguru.developer.com/vb/articles/1966.shtml

    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

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