1. Place 4 controls on a form: Sqlconnection1,simpledataset1,datasource1,dbgrid
(Note: If the "Operation not allowed on unidirectional dataset" error occurs for the following reason:).
Find an article on the internet as follows:
error Description: sqlconnection1, Sqlquery1, Datasource1, and dbgrid1 are used when manipulating the database using the Dbexpress control. In sequential connection, an error occurred when setting the DataSource property of DBGrid to the Datasource1 control: "Operation not allowed on unidirectional dataset".
error Reason: because the SQLQuery control is a one-way cursor, the DBGrid control is bidirectional. The two do not match, so the above error message is generated. (Sqldataset, sqltable are one-way)
So DBGrid cannot be connected to a one-way data set.
Workaround:
(1) Swap with simpledataset;
(2) using Sqlquery+datasetprovider+clientdataset+datasource +dbgrid
2. Setting Method:
SQLConnection1:
SimpleDataSet1
(Note this: After you enter the SQL statement, the active property is set to True, and the DBGrid table displays the contents of the database)
At this point, the contents of the database can be displayed.
DELPHI using dbexpress control to connect MySQL database method