Page 1 of 1

Assertion failure (d:\Projects\Delphi\Mydac\Source\MySqlApi.pas, line 2746)

Posted: Mon 17 Apr 2006 00:22
by Guest
Since moving from Delphi 7 to Delphi 2005 I'm getting this error. I have Update 3 installed for Delphi 2005 and MyDAC version 4.30.0.11.

I'm using mysql embedded with the following code:

Code: Select all

procedure TfrmLogin.btnLoginClick(Sender: TObject);
begin
  try
    localConnection.Connect;
  finally
    localQuery.SQL.Text := 'SELECT * FROM users WHERE username = ' + QuotedStr(editUsername.Text) + ' AND password = OLD_PASSWORD(' + QuotedStr(editPassword.Text) + ') AND active = 1';
    localQuery.Open;

    if (localQuery.RecordCount = 1) then
      begin
      end;
    else
      begin
        editUsername.SetFocus;
        showmessage('Please check your username and password again.');
      end;
      
    localQuery.Close;
    localConnection.Connected := False;
  end;
end;
Also, it doesn't happen all the time. If I get the error, I can generally close the program and restart it and everything will work. Any thoughts on how to fix this would be helpful.

Thanks,
Jesse

Posted: Mon 17 Apr 2006 22:03
by GEswin
I don't know why the error, but just a comment after looking at the code:

the Try ... Finally, if connection fails, rest is executed even when there's no connection and will fail too.. Correct procedure should be to do a try...except and in the except show some msg that you coudln't connect to DB.

Regards

Posted: Tue 18 Apr 2006 03:38
by WarForge00
That first post was me...

I checked out the source code for mydac and it appears that the assertion is happening because of the following files within \data\ directory: ib_logfile0, ib_logfile1, and ibdata1.

When the program closes, I have it doing the following, but it doesn't appear to work.

Code: Select all

  localQuery.Close;
  localConnection.Close;

  DeleteFile('data\ib_logfile0');
  DeleteFile('data\ib_logfile1');
  DeleteFile('data\ibdata1');
  DeleteFile('data\office.err');
If anyone has thoughts, let me know.

Posted: Tue 18 Apr 2006 10:58
by Antaeus
If you use InnoDB tables, you shouldn't delete following files: 'ib_logfile0', 'ib_logfile1', 'ibdata1'. It may cause data loss.
If InnoDB tables aren't used, you should run MySQL embedded server with option --skip-innodb. To enable this option, open TMyEmbConnection editor and check 'Disable InnoDB storage engine' on Params page.