i use acess 97 database , i'm not want to use datacontrol
and iwant to use DBGrid
how can i tie DBGrid with database by code
thank you

First try to understand the Data-bound controls. There is no DBGrid in that. There are DataList, DataCombo and DataGrid controls. Which one You are refering, I am yet understand. And please, while formulating questions try to keep as far as possible the correct spelling and grammar. You are not on a personal chat. You are on a thread that is viewed by many. Remember that.

you cannot use dbgrid without datacontrol because to make dbgrid contain all records from the table you need to first connect the dbgrid with the database and that you cannot do without a control in case of dbgrid.in this case you may face a problem when the database which was set in the control's properties not found in the speicfied location in the system.to overcome this problem you can use this code to dynamically connect the dbgrid with the your database.

data1.databasename=app.path & "\yourdbname.mdb"
data1.recordsource="yourtablename"
data1.refresh

use the above code after doing the following things:-
1.take a dbgrid and a datacontrol
2.set the databasepath and recordsource in datacontrol's properties
3.now set datasource in dbgrid's properties to the name of the datacontrol
4.rightclick dbgrid->select retrieve fields
5.now open datacontrol's properties and delete the values from both databasename and recordsource properties
6.now open code editor and paste the above code in a suitable event

Hi,

DBGrid Cannot be used without datacontrol.

If u want to Set Dynamically, then use DataGrid, U can Set DataSource of a DataGrid To a RecordSet.

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.