SpanishBoy
SpanishBoy

Reputation: 2215

Can't correctly setup SQL Server connection in mORMot

I try to setup connection to SQL Server and catch the error

var
  GFireDACConnProp : TSQLDBFireDACConnectionProperties;
  GFFireDACConn: TSQLDBFireDACConnection;
begin
  try
    GFireDACConnProp := TSQLDBFireDACConnectionProperties.Create('MSSQL?Server=server','dbname','user','pass');
    GFFireDACConn := TSQLDBFireDACConnection.Create(GFireDACConnProp);
    // OR  I := GFireDACConnProp.Execute('Select * from Station', []);
    GFFireDACConn.Connect;
....

Error message:

Project app_.exe raised exception class Exception with message 'Object factory for class {3E9B315B-F456-4175-A864-B2573C4A2101} is missing. To register it, you can drop component [TFDPhysXXXDriverLink] into your project'.

What is correct way to connect to SQL Server and expose REST service?

Upvotes: 0

Views: 1692

Answers (2)

user2663901
user2663901

Reputation: 53

I know its an old thread, but if other come by, it can be fixed just by adding the FireDAC's units to your uses clause e.g.

uses FireDAC.Phys.MSSQL, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.DApt, FireDAC.Stan.Async; // Not sure if you need them all, FireDAC will ask for them

Upvotes: 0

MartynA
MartynA

Reputation: 30715

FireDAC is more helpful than some other frameworks in that when things go wrong the exception messages often say how to fix the problem.

So, in your case, given that the message says "you can drop component [TFDPhysXXXDriverLink] into your project" the thing to try first would be to drop the relevant DriverLink component onto your form/datamodule. As you're using Sql Server, the the driver link to choose would be the TFDPhysMSSqlDriverLink, which is on the FireDAC Links tab of the Component Palette.

If you're creating a Console application, obviously there's no form or datamodule to drop the link on. In that case, create it in code:

FDPhysMSSQLDriverLink := TFDPhysMSSQLDriverLink.Create(Nil);

Upvotes: 1

Related Questions