WormsWorms
asked on
MS Access and Delphi
I have an MS Access DB that I have a front end built for. I am now trying to connect the forms to the DB.
How do I call a query from within delphi and get a result set?
Can someone point me to a tutorial about how to do this? Or a specific example of what stuff I need to put on the form?
I am using Delphi 7 and Access 97.
WormsWorms
How do I call a query from within delphi and get a result set?
Can someone point me to a tutorial about how to do this? Or a specific example of what stuff I need to put on the form?
I am using Delphi 7 and Access 97.
WormsWorms
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi
from ADO components Place one TADOConnection ,one TADOQuery and one DataSource on a form (its better to put the db component in dateModel)
1- connecting database ADOConnection1.connectionS tring := 'Provider=Microsoft.Jet.OL EDB.4.0;Us er ID=Admin;Password=MyPass;D ata Source=C:\employee.mdb;Per sist Security Info=True';
ADOConnection1.LoginPrompt := false;
ADOConnection1.Connected := true;
set ADOQuery1.connection property to ADOConnection1
connect the DataSource with ADOQuery1
2_ Put dbgrid on the form
connect DBgrid with the ADOQuery1 (dataset property of dbgrid)
3_ place bitbtn on the form
4_ Double click on DBgrid and add all FIELDS
5_ in bitbtn1.click procedure place the following code
with ADOQuery1 do begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM EMP');
SQL.Add('WHERE sal >= 250');
Open;
Run the project and click on the bitbtn you will see the result
BRGS
from ADO components Place one TADOConnection ,one TADOQuery and one DataSource on a form (its better to put the db component in dateModel)
1- connecting database ADOConnection1.connectionS
ADOConnection1.LoginPrompt
ADOConnection1.Connected := true;
set ADOQuery1.connection property to ADOConnection1
connect the DataSource with ADOQuery1
2_ Put dbgrid on the form
connect DBgrid with the ADOQuery1 (dataset property of dbgrid)
3_ place bitbtn on the form
4_ Double click on DBgrid and add all FIELDS
5_ in bitbtn1.click procedure place the following code
with ADOQuery1 do begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM EMP');
SQL.Add('WHERE sal >= 250');
Open;
Run the project and click on the bitbtn you will see the result
BRGS
ASKER
Thanks guys. I actually figured it out from the help file.
WormsWorms
WormsWorms
ASKER
And besides, who should I give the points to. 3 people have answers. I actually figured it out from the help file.
BUT, geobul is whining, so I am gonna give him the pionts, and I guess you other guys get screwed.
Sorry
WormsWorms
BUT, geobul is whining, so I am gonna give him the pionts, and I guess you other guys get screwed.
Sorry
WormsWorms
WormsWorms:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
Lets imagine that you need to browse Access data in grid.
So, on form put TDBGrid component, TDataSource, TTable, TDatabase.
Lets set properties:
Database1.DatabaseName:='t
Database1.DriverName:=MSAC
Database1.LoginPromt:=fals
Database1.Params.Clear;
Database1.Params.Add('DATA
');
Database1.Connected:=true;
TDBGrid.DataSource:=DataSo
DataSource1.DataSet:=Table
Table1.DatabaseName:='tryD
Now you can try select for Table1 TableName from List Delphi should offer. After that can set property:
Table1.Active:=true;
Now you must see in Grid1 table data.
Yura