synopse / mORMot2

OpenSource RESTful ORM/SOA/MVC Framework for Delphi and FreePascal
https://synopse.info
Other
516 stars 130 forks source link

Memory Access Violation When Connecting to JET Database #213

Closed Gagogaa closed 1 year ago

Gagogaa commented 1 year ago

Hello mORMot Team,

When connecting to a JET database I get a memory access violation.

I'm using RAD Studio 11 on Windows 11 with mORMot commit eb4123ac07e8975cfdb425f5f06662ce389fefcf.

Minimal steps to reproduce:

  1. Create a new Console application (Windows 32-bit) File -> New -> Console Application - Delphi.

  2. Save the project and replace the contents of Project1.dpr with this:

    
    program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses System.SysUtils, mormot.db.sql, mormot.db.sql.oledb;

var ConnectionProperties : TSqlDbOleDBJetConnectionProperties; Connection : TSqlDBConnection; begin try ConnectionProperties := TSqlDBOleDBJetConnectionProperties.Create('Database1.mdb', '','',''); Connection := ConnectionProperties.NewConnection; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.



3. Run the program. I get a memory access violation on line `Connection := ConnectionProperties.NewConnection;`.
![Screenshot from 2023-08-14 14-09-21](https://github.com/synopse/mORMot2/assets/14839518/f4f1ae32-d720-41c2-af43-3432e200ea4b)

After the program terminates I notice that it has created the `Database1.mdb` file. Re-running the program with the database file in place results in the same error.

I have also run the included test suit and the tests for JET database pass:
![Screenshot from 2023-08-14 14-24-48](https://github.com/synopse/mORMot2/assets/14839518/99d3674f-16cb-468c-b568-899ff88956bb)

Any help connecting to a JET database would be greatly appreciated.

Thank you
synopse commented 1 year ago

Please use https://synopse.info/forum/ for such questions.

Try not to use the connection directly, but rather the high-level methods like ConnectionProperties.Execute().

Also can you show the exact stack trace of the issue?

Gagogaa commented 1 year ago

I just tried replacing the line Connection := ConnectionProperties.NewConnection; with ConnectionProperties.Execute('CREATE TABLE "Users" ("ID" INTEGER, "NAME" TEXT, PRIMARY KEY("ID"));', []); and unfortunately it produces the same error.

I will re-post this question on the form for further comments.

Thank you for your time

synopse commented 1 year ago

There seems to be a regression with TSynLog.Add.

Should be fixed now.

Please try again.

Gagogaa commented 1 year ago

I have updated to the latest commit and it works!

Thank you for the quick responses and a fix