0

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?

Arnaud Bouchez
  • 40,947
  • 3
  • 66
  • 152
SpanishBoy
  • 1,797
  • 4
  • 21
  • 43

1 Answers1

1

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);
MartynA
  • 28,815
  • 3
  • 27
  • 68
  • It's great, however I am using Console Application. What tricks should I perform in this case? – SpanishBoy Sep 08 '15 at 08:57
  • Can't find this class: F2613 Unit 'FireDAC.Phys.MSSQL' not found. Some kind of magic :). Interesting how does mORMot strugle with the issue? – SpanishBoy Sep 08 '15 at 11:16
  • It doesn't sound like it's anything to do with mORMOT, just that the compiler can't find the unit ('FireDAC.Phys.MSSQL.Dcu'). Find it manually on your h/disk, then edit your project's path to include the path to where you found it. – MartynA Sep 08 '15 at 11:36
  • Well, I have that unit in XE8, so I'm not sure why you can't find it. It seems unlikely that Emb have accidentally left it out of Delphi 10. Are you sure FireDAC is supposed to be included in the version you have? There should be a feature matrix on the Emb site which would tell you. – MartynA Sep 08 '15 at 12:10
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/89062/discussion-between-spanishboy-and-martyna). – SpanishBoy Sep 08 '15 at 12:11
  • Sorry, I don't do chats, and as I can't reproduce your error, I don't think I can help any more. – MartynA Sep 08 '15 at 12:18
  • Thanks for the help! I guess this is limitations with Delphi Professional edition – SpanishBoy Sep 08 '15 at 12:30