Click to See Complete Forum and Search --> : Bind a recordset to a DBGrid
Paul_Marlow
Jun 15th, 1999, 07:43 PM
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???
Paul_Marlow
Jun 16th, 1999, 02:09 PM
Anyone know how to do this????
Bavani
Jun 16th, 1999, 03:30 PM
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 ! ! ! !
Paul_Marlow
Jun 16th, 1999, 03:36 PM
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.
LG
Jun 17th, 1999, 06:14 AM
Hi!
sql=" whatever you have "
Set rst=db.OpenRecordset(sql)
Do Until rst.EOF
Data1.Refresh
Data1.RecordSource=sql
rst.MoveNext
Loop
LG
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.