Hi All
First thanks for providing us with this excellent software. I have a problem however. When my app starts up it compares its version against a field in a MySQL db. If not the same the app should shutdown after displaying a message.
Everything works fine except for the app shutting down, it just continues on past the 'Close;' statement...
Below is the code procedure TfrmLogin.FormCreate(Sender: TObject);
{
Need code here to compare the version of the app with the latest one
on the database, if client is not the same error box will come up and
display location to download latest version and then exit application.
}
var
sqlVersion: String;
begin
// Check if we have an active connection. If so, let's close it.
if MySQLConnection1.Connected then
begin
// The SQLTransaction1 gets activated automatically, but before we can close
// the connection we have to set the SQLTransaction1.Active to false.
SQLTransaction1.Active := False;
MySQLConnection1.Close;
end;
// Create the sql statement
sqlVersion := 'select idversion from sasol_kpa.version where version=''' +
APP_VERSION + '''';
// Set the connection parameters.
MySQLConnection1.HostName := DB_HOSTNAME;
MySQLConnection1.UserName := DB_USER;
MySQLConnection1.Password := DB_PASSWD;
MySQLConnection1.DatabaseName := DB_NAME;
// Open the connection.
MySQLConnection1.Open;
// Execute the query
if MySQLConnection1.Connected then
begin
SQLQuery1.SQL.Text := sqlVersion;
SQLQuery1.Open;
if (SQLQuery1.IsEmpty) then
begin
MessageDlg('Error! You need to update your app from \\secdapp30\',mtError, mbOKCancel, 0);
Close;
end;
ShowMessage('Version Correct!');
end;
end;