How to connect MSquery and Dbgrid in XE2

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Mario9
Posts: 8
Joined: Fri 03 Feb 2012 19:51
Location: QUEBEC

How to connect MSquery and Dbgrid in XE2

Post by Mario9 » Fri 03 Feb 2012 20:28

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)

AndreyZ

Post by AndreyZ » Mon 06 Feb 2012 11:49

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

Mario9
Posts: 8
Joined: Fri 03 Feb 2012 19:51
Location: QUEBEC

Very good anwser

Post by Mario9 » Mon 06 Feb 2012 14:15

Thank you for your help

My programm is ok


Very appréciate your information


Mario

AndreyZ

Post by AndreyZ » Mon 06 Feb 2012 15:22

If any other questions come up, please contact us.

Post Reply