#1 2016-01-28 17:41:30

gjrivero
Member
Registered: 2014-02-05
Posts: 3

"Class not registered"

Hello!

I'm working with mormot 1.18, Delphi Seattle, MSSQL 2014

I Change the Sample 28 (simple RESTful ORM Server)  to TOleDBMSSQLConnectionProperties for to work with MSSQL 2014 database

I'm creating the MSSQL tables from TSQLModel.

When the application execute CreateMissingTables, then the following error occurs "Class not registered"


This is the code TSQLModel:

unit uClassDef;
{$I Synopse.inc} // define HASINLINE WITHLOG USETHREADPOOL ONLYUSEHTTPSOCKET

interface

uses
{$I SynDprUses.inc}
  SysUtils,
  SynCommons,
  SynCrypto,
  mORMot;

Type

  TSQLUserGroups = Class(TSQLRecord)
  private
    fHeader: Integer;
    fDescrip: RawUTF8;
    fSettings: TNullableUTF8Text;
  public
  published
    property Header: Integer read fHeader write fHeader;
    property Descrip: RawUTF8 Index 60 read fDescrip write fDescrip;
    property Settings: TNullableUTF8Text read fSettings write fSettings;
  End;

  TSQLUsers = Class(TSQLRecord)
  private
    fmGroup: TSQLUserGroups;
    fHeader: Integer;
    fSettings: TNullableUTF8Text;
    fDescrip: RawUTF8;
  public
  published
    property mGroup: TSQLUserGroups read fmGroup write fmGroup;
    property Header: Integer read fHeader write fHeader;
    property Descrip: RawUTF8 Index 60 read fDescrip write fDescrip;
    property Settings: TNullableUTF8Text read fSettings write fSettings;
  End;

  TSQLAddress   = Class(TSQLRecord)
  private
    fDescrip: RawUTF8;
    fCountry: RawUTF8;
    fState: RawUTF8;
    fLocality: RawUTF8;
    fAddress1: RawUTF8;
    fAddress2: RawUTF8;
    fzipCode: RawUTF8;
    fPhones: RawUTF8;
  public
  published
    property Descrip: RawUTF8 Index 60 read fDescrip write fDescrip;
    property Country: RawUTF8 Index 40 read fCountry write fCountry;
    property State: RawUTF8 Index 20 read fState write fState;
    property Locality: RawUTF8 Index 40 read fLocality write fLocality;
    property Address1: RawUTF8 Index 60 read fAddress1 write fAddress1;
    property Address2: RawUTF8 Index 60 read fAddress2 write fAddress2;
    property zipcode: RawUTF8 Index 15 read fzipCode write fzipCode;
    property Phones: RawUTF8 Index 60 read fPhones write fPhones;
  End;

  TPersonTypes = (ptDefault,ptCustomer,ptVendor,ptSalesman,ptServers);

  TSQLPerson = Class(TSQLRecord)
  private
    fPersonId: RawUTF8;
    fpType: Int8;
    fBirthDate: TCreateTime;
    fpClass: RawUTF8;
    fEmail: RawUTF8;
    fLastName: RawUTF8;
    fIdType: Int8; 
    fTaxId: RawUTF8;
    fDescrip: RawUTF8;
    fNametype: Int8;   
    fFirstName: RawUTF8;
    fActive: Int8;
    fNotes: TNullableUTF8Text;
    fAddress: TSQLAddress;
  public
    function Name: RawUTF8;
  published
    property personId: RawUTF8 Index 15 read fPersonId write fPersonId stored AS_UNIQUE;
    property pType: Int8 read fpType write fpType;
    property Active: Int8 read fActive write fActive;
    property TaxId: RawUTF8 Index 25 read fTaxId write fTaxId;
    property IdType: Int8 read fIdType write fIdType;        
    property NameType: Int8  read fNametype write fnametype; 
    property FirstName: RawUTF8 index 20 read fFirstName write fFirstName;
    property LastName: RawUTF8 index 20 read fLastName write fLastName;
    property Descrip: RawUTF8 Index 60 read fDescrip write fDescrip;
    property Address: TSQLAddress read fAddress write fAddress;
    property pClass: RawUTF8 Index 15 read fpClass write fpClass;
    property BirthDate: TCreateTime read fBirthDate write fBirthDate;
    property Email: RawUTF8 index 60 read fEmail write fEmail;
    property Notes: TNullableUTF8Text read fNotes write fNotes;
  End;

  TSQLConfigSys = Class(TSQLRecord)
  private
    fSettings: TNullableUTF8Text;
    fdPrivate: TSQLRawBlob;
    fAddress: TSQLAddress;
    fIdVersion: Int64;
  public
  published
    property Settings: TNullableUTF8Text read fSettings write fSettings;
    property dPrivate: TSQLRawBlob read fdPrivate write fdPrivate;
    property address: TSQLAddress read fAddress write fAddress;
    property Idversion: Int64 read fIdVersion write fIdVersion;
  End;

  TSQLCorrelative = Class(TSQLRecord)
  private
    fConfig: TSQLConfigSys;
    fFieldName: RawUTF8;
    fValue: RawUTF8;
    fStation: RawUTF8;
  public
  published
    property Config: TSQLConfigSys read fConfig write fConfig;
    property fieldname: RawUTF8 Index 15 read fFieldName write ffieldName;
    property Station: RawUTF8 Index 15 read fStation write fStation;
    property Value: RawUTF8 Index 10 read fValue write fValue;
  End;

  TSQLCustomers = Class(TSQLRecord)
  private
    fPerson: TSQLPerson;
    fzoneCode: RawUTF8;
    fTolerance: Int16;
    fAgreeCode: RawUTF8;
    fDiscount: Double;
    fCustType: Int8;
    fSalesCode: RawUTF8;
    fCredit: Double;
    fCreditdays: Int16;
    fPricetype: Int8;
  public
  published
    property person: TSQLPerson read fPerson write fPerson;
    property CustType: Int8 read fCustType write fCustType;  // Contribuyente,C.Final,Gobierno
    property PriceType: Int8 read fPricetype write fPriceType;
    property ZoneCode: RawUTF8 index 10 read fzoneCode write fzoneCode;
    property SalesCode: RawUTF8 index 10 read fSalesCode write fSalesCode;
    property AgreeCode: RawUTF8 index 10 read fAgreeCode write fAgreeCode;
    property Credit: Double read fCredit write fCredit;
    property CreditDays: Int16 read fCreditdays write fCreditdays;
    property Tolerance: Int16 read fTolerance write fTolerance;
    property Discount: Double read fDiscount write fDiscount;
  End;

  TSQLSalesMen = Class(TSQLRecord)
  private
    fPerson: TSQLPerson;
  public
  published
    property person: TSQLPerson read fPerson write fPerson;

  End;

  TSQLServers = Class(TSQLRecord)
  private
    fPerson: TSQLPerson;
  public
  published
    property person: TSQLPerson read fPerson write fPerson;

  End;

  TSQLVendors = Class(TSQLRecord)
  private
    fPerson: TSQLPerson;
  public
  published
    property person: TSQLPerson read fPerson write fPerson;

  End;

  TSQLInstance =Class(TSQLRecord)
  private
  public
  published
  End;

  TSQLInventory =Class(TSQLRecord)
  private
  public
  published
  End;

  TSQLLocation =Class(TSQLRecord)
  private
  published
  End;

  TSQLUser = class(TSQLAuthUser)
  private
  published
  end;


const
  SERVER_ROOT = 'root';
  SERVER_PORT = '8092';
  SERVER_HOST = 'localhost';


function DataModel: TSQLModel;

implementation

uses
  SynCrtSock;

function DataModel: TSQLModel;
begin
  Result:= TSQLModel.Create([TSQLUSerGroups,TSQLUsers,TSQLAddress,
     TSQLPerson,TSQLConfigSys,TSQLCorrelative, TSQLCustomers],SERVER_ROOT);
  //TPerson.AddFilterOrValidate('Name',TSynValidateText.Create); // ensure exists
end;


function TSQLPerson.Name: RawUTF8;
begin
  if IdType=1 then
     Result:=Descrip
  else
     Result:=FirstName+' '+LastName;
end;

end.

This is the server:

uses
{$I SynDprUses.inc}
 SynCrtSock,
 SynCommons,
 SynSQLite3,
 SynDBRemote,
 SynSQLite3Static,
 SynDB,
 SynLog,
 SynOleDB,
 mORMot,
 mORMotDB,
 mORMotSQLite3,
 mORMotHttpServer,
 uClassDef in 'uClassDef.pas';


procedure setVirtualTables( aModel: TSQLModel;
                            aProps: TOleDBMSSQLConnectionProperties);
Begin
  VirtualTableExternalRegister(aModel,TSQLUSerGroups, aProps,'dbo.UserGroups');
  VirtualTableExternalRegister(aModel,TSQLUsers,      aProps,'dbo.Users');
  VirtualTableExternalRegister(aModel,TSQLAddress,    aProps,'dbo.Address');
  VirtualTableExternalRegister(aModel,TSQLPerson,     aProps,'dbo.Person');
  VirtualTableExternalRegister(aModel,TSQLConfigSys,  aProps,'dbo.ConfigSys');
  VirtualTableExternalRegister(aModel,TSQLCorrelative,aProps,'dbo.Correlative');
  VirtualTableExternalRegister(aModel,TSQLCustomers,  aProps,'dbo.Customers');

  VirtualTableExternalRegisterAll(aModel,aProps);
End;

var
  aModel: TSQLModel;
  aProps: TOleDBMSSQLConnectionProperties;
  aRestServer: TSQLRestServerDB;
  aHttpServer: TSQLHttpServer;
begin
  SQLite3Log.Family.Level := LOG_VERBOSE;
  SQLite3Log.Family.PerThreadLog := ptIdentifiedInOnFile;
  aProps := TOleDBMSSQLConnectionProperties.Create('localhost','Elevated','sa','12345');
  try
    aModel := DataModel;
    setVirtualTables(aModel,aProps);
    try
      aRestServer := TSQLRestServerDB.Create(aModel,':memory:',false); // authentication=false
      try
        aRestServer.AcquireExecutionMode[execORMGet  ]:= amBackgroundORMSharedThread;
        aRestServer.AcquireExecutionMode[execORMWrite]:= amBackgroundORMSharedThread;
        aRestServer.DB.Synchronous:=smNormal;
        aRestServer.DB.LockingMode:=lmExclusive;
        // create tables or fields if missing
        aRestServer.CreateMissingTables;
        // serve aRestServer data over HTTP
        aHttpServer := TSQLHttpServer.Create(SERVER_PORT,[aRestServer],'+',useHttpApiRegisteringURI);
        try
          aHttpServer.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
          writeln('Background server is running.'#10);
          write('Press [Enter] to close the server.');
          readln;

This is the log file

20160128 17192111  ! DB    	SynSQLite3.TSQLDatabase(02D3A820) ":memory:" database file opened with PageSize=1024 and CacheSize=2000
20160128 17192111  !  -    00.000.185
20160128 17192111  ! SQL   SynSQLite3.TSQLDatabase(02D3A820) 5us  PRAGMA synchronous=1
20160128 17192111  ! SQL   SynSQLite3.TSQLDatabase(02D3A820) 2us  PRAGMA locking_mode=EXCLUSIVE;
20160128 17192111  ! SQL   SynSQLite3.TSQLDatabase(02D3A820) 20us  returned 0 rows SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%';
20160128 17192111  ! DB    mORMotSQLite3.TSQLRestServerDB(02C10030) CreateMissingTables on {"TSQLDatabase(02D3A820)":{"FileName":":memory:","IsMemory":true,"UseCache":true,"TransactionActive":false,"BusyTimeout":0,"CacheSize":2000,"PageSize":1024,"PageCount":0,"FileSize":0,"WALMode":false,"Synchronous":"smNormal","LockingMode":"lmExclusive","MemoryMappedMB":0,"user_version":0,"OpenV2Flags":6,"BackupBackgroundInProcess":false,"BackupBackgroundLastTime":"","BackupBackgroundLastFileName":"","SQLite3Library":{"TSQLite3LibraryStatic(02C975F0)":{"Version":"3.10.2 with internal MM"}}}}
20160128 17192111  ! DB    mORMotSQLite3.TSQLRestServerDB(02C10030) "GetTables":[]
20160128 17192111  ! SQL   SynSQLite3.TSQLDatabase(02D3A820) 2us  BEGIN TRANSACTION;
20160128 17192111  !  +    mORMotDB.TSQLRestStorageExternal(02C9F4E0).Create TSQLUserGroups
20160128 17192111  ! info  	mORMotDB.TSQLRestStorageExternal(02C9F4E0) TSQLUserGroups {"TOleDBMSSQLConnectionProperties(02C79C30)":{"ProviderName":"SQLNCLI10","Engine":"MSSQL","ServerName":"localhost","DatabaseNameSafe":"Elevated","UserID":"sa","DBMS":"dMSSQL","DBMSEngineName":"MSSQL","BatchSendingAbilities":["cCreate"],"BatchMaxSentAtOnce":4096,"LoggedSQLMaxSize":0,"LogSQLStatementOnException":false,"ForcedSchemaName":"dbo","UseCache":true,"RollbackOnDisconnect":true,"StoreVoidStringAsNull":true}} Server={"TSQLRestServerDB(02C10030)":{"DB":{"TSQLDatabase(02D3A820)":{"FileName":":memory:","IsMemory":true,"UseCache":true,"TransactionActive":true,"BusyTimeout":0,"CacheSize":2000,"PageSize":1024,"PageCount":1,"FileSize":1024,"WALMode":false,"Synchronous":"smNormal","LockingMode":"lmExclusive","MemoryMappedMB":0,"user_version":0,"OpenV2Flags":6,"BackupBackgroundInProcess":false,"BackupBackgroundLastTime":"","BackupBackgroundLastFileName":"","SQLite3Library":{"TSQLite3LibraryStatic(02C975F0)":{"Version":"3.10.2 with internal MM"}}}},"StatementLastException":"","NoAJAXJSON":false,"Options":[],"HandleAuthentication":false,"BypassORMAuthentication":[],"Stats":{"StartDate":"2016-01-28 17:19:21","Success":0,"ServiceMethod":0,"ServiceInterface":0,"OutcomingFiles":0,"CurrentThreadCount":0,"Created":0,"Read":0,"Updated":0,"Deleted":0,"ClientsCurrent":0,"ClientsMax":0,"CurrentRequestCount":0,"Input":{"Bytes":0,"Text":"0 B"},"Output":{"Bytes":0,"Text":"0 B"},"InputThroughput":{"BytesPerSec":0,"Text":"0 B/s"},"OutputThroughput":{"BytesPerSec":0,"Text":"0 B/s"},"Processing":false,"TaskCount":0,"TotalTime":{"MicroSec":0,"Text":"0us"},"LastTime":{"MicroSec":0,"Text":"0us"},"MinimalTime":{"MicroSec":0,"Text":"0us"},"AverageTime":{"MicroSec":0,"Text":"0us"},"MaximalTime":{"MicroSec":0,"Text":"0us"},"PerSec":0,"Errors":0,"LastError":null},"StatLevels":["mlTables","mlMethods","mlInterfaces","mlSQLite3"],"StaticVirtualTableDirect":true,"ServerTimeStamp":135295079637}}
20160128 17192111  !  +    	SynOleDB.TOleDBConnection(02C46BB0).005EEA1D 
20160128 17192111  !  -    	00.002.587
20160128 17192111  !  +    	SynOleDB.TOleDBConnection(02C46BB0).005EE7A2 
20160128 17192127  ! EXC   		EOleSysError 80040154 ("Class not registered") at 005E6239  stack trace API 00540EF4 00540F1C 0040A808 
20160128 17192127  ! ERROR 		"EOleSysError(02D09188)":"Class not registered" stack trace API 00542FE0 005EE921 0056A149 005EC844 005592CF 0055B337 0055ABF6 0055EC8F 005EFB9A 006AA75D 006AABAA 0068F7FA 006B7B56 005BD814 005BDBD7 00597CC8 00590E47 00590F44 0054EDE5 0054DAFA 0054DBA7 0054ADBF 006B3743 006CA53D 77BA38F4 77CD56C3 77CD568E 
20160128 17192127  ! EXC   		EOleSysError 80040154 ("Class not registered") at 005E6239  stack trace API 00540EF4 00540F1C 0040A808 
20160128 17192127  !  -    	00.246.829
20160128 17192127  ! DB    	SynOleDB.TOleDBStatement(02E59B10) Rows = {"TOleDBStatement(02E59B10)":{"SQL":"select COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE, 0 INDEX_COUNT from INFORMATION_SCHEMA.COLUMNS where UPPER(TABLE_SCHEMA) = 'DBO' and UPPER(TABLE_NAME) = 'USERGROUPS'","SQLWithInlinedParams":"select COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE, 0 INDEX_COUNT from INFORMATION_SCHEMA.COLUMNS where UPPER(TABLE_SCHEMA) = 'DBO' and UPPER(TABLE_NAME) = 'USERGROUPS'","CurrentRow":0,"TotalRowsRetrieved":0,"Connection":{"TOleDBConnection(02C46BB0)":{"Connected":false,"ServerTimeStampAtConnection":"","TotalConnectionCount":0,"TransactionCount":0,"InTransaction":false,"RollbackOnDisconnect":true,"LastErrorMessage":"","LastErrorWasAboutConnection":false,"Properties":{"TOleDBMSSQLConnectionProperties(02C79C30)":

Offline

#2 2016-01-28 21:32:01

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

Re: "Class not registered"

Your computer does not have the expected OleDB provider installed.

Try with one of the other TOleDBMSSQL*ConnectionProperties classes.

Offline

#3 2016-01-28 21:53:08

gjrivero
Member
Registered: 2014-02-05
Posts: 3

Re: "Class not registered"

Thanks a lot!

Offline

Board footer

Powered by FluxBB