Delphi TAdoConnection Master/Detail : duplicate records in grid - delphi

I made the following test for the problem. I have a TAdoConnection connected with an Access database with two tables (master/detail);
A TADoDataset with commandtext selecting the master table, a DatasetProvider conneced to the AdoDatset and a Clientdataset to the provider and a Datasource.
The same (4) components for the Detail set. On the main form two DBgrids.
Nothing special. But the one of the master records does not have detail records.
When I scroll trough the master grid, after having selected the record without details, the details of the other masters are duplicated: a master with 3 details shows 6 and next time 9 etc.
This only happens with TAdoDataset, DataProvider, Clientdataset. When I use a TSQLConnection and a TSQLDataset the behaviour is normal. But in my current project I have to deal with TAdoDataset. Please help.

Related

How to fix the DevExpress TcxGrid GridMode using a TSQLDataSet linked to a TSQLQuery?

I'm trying to load about 500k+ data linked to an Oracle DB on my TcxGrid, I want to make the process faster using the GridView "GridMode" property, but I need to do that using a TSQLQuery (DBExpress Component) and it just doesn't work, Gridmode seems inoperable (doesn't load data faster on the Grid, doesn't load custom quantity of records using the "BufferCount" property, etc.)
Here I created a TSQLQuery component and used a query script for my 500k table (for performance purposes I just got 500 values but I need to load 500k+):
TSQLQuery
When I link the TSQLDataSet to the Grid and activate the TSQLQuery it shows all the records from the query, even if the GridMode is TRUE and the GridModeBufferCount is 5
GridWithTSQLQuery
On the other hand, when I use a TQuery, the GridMode just works properly, in this case I had to open SQL Explorer, make the connection and assign that connection to the TQuery DataBase property:
SQLExplorer
Here I show my TQuery with the values mentioned before:
TQuery
And when I activate my TQuery.. voilá:
GridWithTQuery
What I'm doing wrong? or do I need to do more things on my TSQLQuery besides linking it to my dataset and then linking the dataset to the grid?
It's impossible that a very old Tquery can do this and not a newer dbExpress component
Thank you so much guys

How to use Microsoft Access In your login form for delphi

OK, so I am a self taught basic coder by watching videos on how to do basic coding with Delphi and i have successfully created an application where i use a text file for a login form with usernames and passwords being checked (with a lot of help from videos). How can i use Microsoft Access for the login for the username and a password? I struggle to find a video on how it works. I found a video telling me how to connect ado tables and connections, but i am struggling with the login. Any help would be appreciated.
If you can follow the video about Ado tables, all you are missing is how to configure the TAdoConnection you use to connect to the database. Assuming you've got the project set up:
In the IDE, click your TAdoConnection - usually it would be called AdoConnection1 by default.
In the Object Inspector, click AdoConnection1's ConnectionString property.
In the Data Link properties pop-up, select the MS Office 12.0 Access Database Engine OLE DBProvider (the version number may be different on your system), then click `Next'.
On the next tab, in item 1, enter your database's exact name and extension, including the full path to it.
In item 2, enter the User name
Then click Test connection. Assuming you get Test connection succeeded, you're done.
Try that and see how you get on.
Btw, very occasionally you may come across Delphi Ado projects that don't have a TAdoConnection; in that case, you configure the connection of the TAdoDataSet component (e.g. a TAdoTable) by the above method.
If you would prefer to start with a blank form and set it up from scratch yourself, do the following before the above steps:
Place the followinng components on the form: a TAdoConnection; a TAdoTable; a TDataSource (on the Data Access tab of the Component Palette); a TDBGrid and a TDBNavigator (both on the Data controls tab. Then wire them up as follows:
In the Object Inspector set the DataSource properties of DBNavigator1 and DBGrid1 to DataSource1
Set DataSource1's DataSet property to AdoTable1
Set AdoTable1's Connection property to AdoConnection1
Then, configure AdoConnection1 as detailed above.
Finally
Set AdoTable1's TableName property to the name of a table in your database, thn set its Active property to True.
Compile and run.
Once you've got it working, set AdoTable1's Active property to False and instead set it to open in Form1's FormCreate event. You can also set AdoConnection1's LoginPrompt to False if you prefer.

TADODataSet.MasterFields - Performance

I have a Delphi application which has 2 TADODataSet objects that reference CLIENT (Master) and ORDER (detail) data. I have the 2 components linked via the DataSource and Masterfields (using ClientCode) properties and everything functions as expected. However, I've noticed a performance issue recently and have discovered that even if only just one client record is returned for for the master record set, the entire orders table is returned and then filtered for the specific client. Is this how it should function? From tracing the database activity I can see that the following SQL is being executed:
-- the one client that I wanted to view
SELECT fields FROM Client WHERE ClientCode = 1;
SELECT fields from Order; -- entire orders table
I am using Delphi 2006 BDS
You just have to watch that Masterfield is named correctly with the fieldname of your masterdataset.
Make sure the parameter types are the same in both cases, i.e. master and child.

DataSnap Master/Detail Relationship - Post raises exception with message "No corresponding master record found"

A duplicate of this question, but since the answer there wasn't accepted I thought maybe there's a workaround.
I have two TSQLTable components on my datasnap server which are in a master/detail relationship, and one TDataSetProvider linked to the master table. On my client application, there are two TClientDataSet components, of which one is nested in the other naturally. When I try to post a new record to the detail dataset, even before calling ApplyUpdates(), the mentioned exception is raised. Is this really a bug in XE2? How to work around it?
Here's the diagram SSMS generated for the tables:
I assume the master detail relation is by CenterID -> ID. This does not work as expected.
The Midas internals require to use the same field name in both datasets to establish a master detail relationship. Giving your layout it tries to establish a relation using the ID field in both tables.
To resolve this rename the ID field in Centers to CenterID.

Delphi with Intraweb 8 - TIWDBLookupComboBox - master detail

I'm building an application using IW 8 and Delphi 7. Application is 3-tier.
1) on the app's datamodule I have several TClientDatasets and TDataSources associated(set on master-detail relationship)
2) on an IW form I have several TIWDBLookupComboBoxes with datasets pointed to datamodule datasources.
The problem I'm facing: when I select a value from one of the TIWDBLookupComboBoxes, the datasets don't react(I'm changing the index of the master dataset, so the detail dataset should also change). So I saved the clientdatasets to xml files and imported the data into a win32 application, set all the master details in the same manner, and voila - everything is ok.
So my question is: it seems that TIWDBLookupComboBoxes don't move the internal cursor of the datasets? If so, on the OnChange event of the TIWDBLookupComboBoxes, if I set the recno to what I want I'll have problems with forms rendering?
how can I solve this?
I resolved this by using simple IWComboBox components, and on the OnChange event setting up the RecNo property to the combobox's index+1(itemindex is 0 based). Other solution is to make a filter on the dataset with the combobox's value.

Resources