Page 1 of 1

How to connect MSquery and Dbgrid in XE2

Posted: Fri 03 Feb 2012 20:28
by Mario9
Hi

I test SDAC I'm not spécialist with Sql.I always use BDE with delphi.

I will like to connect my Dbgrid with the awnser Msquery.

What do yo do for connect information.

Please explain the base first.

1- Msconnection1 is ok
2- Mstable1 is active
3- Msdatasource1 is connect with mstable1
4-my Dbgrid is connect on MSdatasource1
I see my information table
5- I put active my Msquery1 and I dont see a changement in my Dbgrid
Why?

Thank you for your Help!

Mario(excuse my english)

Posted: Mon 06 Feb 2012 11:49
by AndreyZ
Hello,

The TDBGrid component shows data only from the dataset that is specified in the TDBGrid.DataSource.DataSet property. To make TDBGrid show data of another dataset, you can use two ways:
- set the TDBGrid.DataSource property to a datasource that is linked to another dataset. Here is an exmaple:

Code: Select all

MSDataSource1.DataSet := MSTable1;
MSDataSource2.DataSet := MSQuery1;
DBGrid.DataSource := MSDataSource1; // now TDBGrid shows the data of MSTable1
DBGrid.DataSource := MSDataSource2; // now TDBGrid shows the data of MSQuery1
- set the TDBGrid.DataSource.DataSet property to another dataset. Here is an example:

Code: Select all

MSDataSource1.DataSet := MSTable1;
DBGrid.DataSource := MSDataSource1; // now TDBGrid shows the data of MSTable1
MSDataSource1.DataSet := MSQuery1; // now TDBGrid shows the data of MSQuery1

Very good anwser

Posted: Mon 06 Feb 2012 14:15
by Mario9
Thank you for your help

My programm is ok


Very appréciate your information


Mario

Posted: Mon 06 Feb 2012 15:22
by AndreyZ
If any other questions come up, please contact us.