You are not logged in.
I get the following Error message:
Project TestExtDBConnection.exe raised exception class EOleDBException with message 'TSqlDBOleDBConnection: OleDB error [] (0x80040E14) - (line 1): Could not create constraint or index. See previous errors.
(line 1): Column 'CustomerID' in table 'Customer' is of a type that is invalid for use as a key column in an index.'.The ORM-table:
TOrmCustomer = class(TOrm)
private
fName: RawUTF8;
fCustomerID: RawUTF8;
published
property Name: RawUTF8 read fName write fName;
property CustomerID: RawUTF8 read fCustomerID write fCustomerID stored AS_UNIQUE;
end;Some code:
function CreateOSModel: TOrmModel;
begin
result := TOrmModel.Create([TOrmCustomer]);
end;
var
model: TOrmModel;
props: TSQLDBConnectionProperties;
RestServer: TRestServerDB;
begin
model := CreateOSModel;
Props := GetODBCDriverSpec.Create('MyServer', 'MyDB', '', '');
VirtualTableExternalRegister(Model, TOrmCustomer, props, 'dbo.Customer');
RestServer := TRestServerDB.Create(Model, ':memory:');
RestServer.CreateMissingTables; <<<---- Getting error here.Last edited by larand54 (2025-12-19 23:47:21)
Delphi-11, WIN10 and Win11
Offline
I Use Microsofts sql server and there is no table in the database it should have been created by "CreateMissingTables".
Delphi-11, WIN10 and Win11
Offline
On MS SQL Server, you need to specify a length to the RawUtf8 field, so that it creates a VARCHAR field.
Currently, it creates a CBLOB which can't be indexed on MS SQL, by definition.
Look at the SQL generated to create the table and the index, and you will find it.
Offline