#1 2018-11-27 18:53:20

Beertjie
Member
From: South Africa
Registered: 2018-09-09
Posts: 14

SQL Server 2005 Express

I'm trying to use mORMot with SQL Server 2005 Express.

My code is a lot like andrey's code in this old thread, except I haven't had any luck with OLE (I keep getting "class not registered").

With ODBC, I've gotten a bit further. If I create the database ORMPOCTest beforehand, I am able to connect with the connection properties below:

FProps := TODBCConnectionProperties.Create('', 'Driver={SQL Native Client};Server=.\SQLExpress;Database=ORMPOCTest;Trusted_Connection=yes;', '', '');

I follow this up with:

FModel := TSQLModel.Create([TMovie, TBook]);
VirtualTableExternalRegister(FModel, [TMovie, TBook], FProps);
FServerDB := TSQLRestServerDB.Create(FModel, ':memory:');
FServerDB.CreateMissingTables;

The tables are created. Everything looks good. Now...

NewBook := TBook.Create;
try
  NewBook.Title := 'The Last Wish';
  NewBook.Author := 'Andrzej Sapkowski';
  NewBook.ISBN := '9780316029186';

  NewID := FServerDB.Add(NewBook, True);
finally
  NewBook.Free;
end;

I used this same code with straight-up SQLite3 and it worked. But here I get this error message:

TODBCStatement - TODBCLib error: [HY000] [Microsoft][ODBC Driver 13 for SQL Server]Connection is busy with results for another command (0)

Similarly, I have test code for retrieving, updating, and deleting records. With this connection, all of them fail with the above error.

Except for my RetrieveList code,

SearchResults := FServerDB.RetrieveList(TMovie, 'RunningTime > ? AND Released >= ?', [130, DateToSQL(2000, 5, 7)]);

This fails with a different error:

TODBCStatement - TODBCLib error: [HYC00] [Microsoft][ODBC Driver 13 for SQL Server]Optional feature not implemented (0)

I get the same results for all the drivers below:

  • SQL Native Client

  • SQL Server Native Client 11.0

  • ODBC Driver 13 for SQL Server

Any suggestions on what I could be doing wrong here?

P.S. I realize that Microsoft hasn't supported SQL Server 2005 since April 2016.

Offline

#2 2018-11-28 00:10:31

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,243
Website

Re: SQL Server 2005 Express

1. Ensure the driver is the same bitness (32-bit or 64-bit) than your mORMot application.

2. Try with an external ODBC tool to validate your settings and SQL expectations.

Offline

#3 2018-12-01 10:08:11

Beertjie
Member
From: South Africa
Registered: 2018-09-09
Posts: 14

Re: SQL Server 2005 Express

You're right, the problem is definitely my ODBC driver. Finding a 32-bit one for 2005 that works on 64-bit Windows 7 might prove difficult.

In the meantime, I got the OLE connection working. I was using the wrong connection properties class – it should have been TOleDBMSSQL2005ConnectionProperties. Works beautifully now!

Offline

Board footer

Powered by FluxBB