0
下面的代码是从文档here:拉撒路帕斯卡尔 - DB连接 - 澄清
Program ConnectDB
var AConnection : TSQLConnection;
Procedure CreateConnection;
begin
AConnection := TIBConnection.Create(nil);
AConnection.Hostname := 'localhost';
AConnection.DatabaseName := '/opt/firebird/examples/employee.fdb';
AConnection.UserName := 'sysdba';
AConnection.Password := 'masterkey';
end;
begin
CreateConnection;
AConnection.Open;
if Aconnection.Connected then
writeln('Succesful connect!')
else
writeln('This is not possible, because if the connection failed, ' +
'an exception should be raised, so this code would not ' +
'be executed');
AConnection.Close;
AConnection.Free;
end.
代码的主体是有道理的我,但我不明白其中TSQLConnection
是从哪里来的。我不能使用CTRL +空格自动完成它,这意味着我的程序没有提及它。顺便说一下,我试图连接到Postgres。
有人能说出什么TSQLConnection
是什么?谢谢!
如果我包含pqconnection单元,是不是应该自动完成?我不明白。 – itsols
不,为了获得自动完成功能,您必须在此处包含定义类型的单位,即'sqldb'单位。 – RRUZ
@itsols有什么关系的PostGreSQL单位到Firebird数据库服务器?为什么你有这个想法来包含** pq **连接。 PS。你可以搜索'Unified Interbase'组件集 - 也许有人将它们移植到FPC。 –