Connection := TSQLConnection.Create(nil);
SqlSet := TSQLDataSet.Create(nil);
Connection.DriverName := 'MySQL';
Connection.GetDriverFunc := 'getSQLDriverMYSQL';
Connection.LibraryName := 'dbxmys.dll';
Connection.VendorLib := 'libmysql.dll';
SqlSet.CommandText:= 'SELECT VERSION()';
DataSrc := TDataSource.Create(Self);
DataSrc.DataSet := ADOQuery;
DataSrc.Enabled := true;
DBGrid1.DataSource := DataSrc;
You're using the wrong method. In any of the
TDataSet descendants that have it,
ExecSQL is for executing queries that return no result set, such as INSERT, UPDATE, DELETE, or CREATE TABLE. See, for instance,
TSQLQuery.ExecSQL (emphasis mine)
Executes a query that does not return a set of records.
Call ExecSQL to execute an SQL command that does not return a set of records. This command is a query other than a SELECT query, such as an INSERT, UPDATE, DELETE, or CREATE TABLE query.
TSQLQuery.Open to return rows from a SELECT. Something like this should work (untested - I don't use MySQL or DBExpress):
var Qry: TSQLQuery; VersionString: String; // Set up your connection as above, and open it Qry := TSQLQuery.Create(nil); Qry.SQLConnection := Connection; Qry.SQL.Text := 'SELECT VERSION() as DBVersion'; Qry.Open; if not Qry.IsEmpty then VersionString := Qry.FieldByName('DBVersion').AsString else VersionString := 'No results found'; Qry.Close;
For more information (including step-by-step tutorials), see Using DBExpress Components at the Delphi docwiki. (The one I've linked is for the current Delphi version, but the basic steps for DBExpress are the same since it was introduced.)
If you want a basic video tutorial for using DBExpress in Delphi, you can try DBExpress Data Access Components in Delphi - Delphi 101. I haven't watched it, but it was posted by Embarcadero, the makers of Delphi.