Results 1 to 5 of 5

Thread: Bind a recordset to a DBGrid

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Location
    Aberdeen
    Posts
    4

    Post

    Im trying to display the contents of a recordset in a dbgrid. The data source of the grid is a data control (data1) and Im assigning my recordset to the data controls recordset property. The dbgrid expands vertically to the correct number of rows but no data is displayed.

    Does anyone know what im doing wrong???

  2. #2

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Location
    Aberdeen
    Posts
    4

    Post

    Anyone know how to do this????

  3. #3
    New Member
    Join Date
    Jun 1999
    Location
    Chennai, Tamilnadu, India
    Posts
    4

    Post

    Hai
    First set the database name of data1 to the desired database.(ex. Emp.mdb) then recordset property of data1 to the table name you require.
    Set the dbgrid datasource to Data1. This will fetch the details of the table you have selected provided you have records in that. so check you have records in the table

    ------------------
    Doing what you like is Freedom ! ! ! !
    Liking what you do is Happiness ! ! ! !

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Location
    Aberdeen
    Posts
    4

    Post

    OK, but the problem is that I want to display results from a SQL statement (eg Only display records where the employee ID matches that specified by the user).

    I execute the SQL statement against the database so I have my data in a recordset. The problem is getting the data from the recordset to the dbgrid.

  5. #5
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    Hi!
    sql=" whatever you have "
    Set rst=db.OpenRecordset(sql)
    Do Until rst.EOF
    Data1.Refresh
    Data1.RecordSource=sql
    rst.MoveNext
    Loop

    LG


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