以编程方式设置TSQLConnection属性

6St*_*der 0 delphi delphi-xe8

使用TSQLConnection组件,如果我将Driver属性设置为DataSnap有没有办法在代码中手动设置该驱动程序的属性?

例如CommunicationProtocolCommunicationIPVersion.

任何帮助,将不胜感激.

谢谢,

Uwe*_*abe 7

嗯,SilverWarior描述的并不是那么简单.问题是这些属性是特定于驱动程序的,不能直接从TSQLConnection访问.好的,这是一种方式:

var
  dbxProps: TDBXDatasnapProperties;
begin
  Assert(SQLConnection1.DriverName = 'DataSnap', 'Driver must be DataSnap');
  dbxProps := SQLConnection1.ConnectionData.Properties as TDBXDatasnapProperties;
  dbxProps.CommunicationProtocol := 'tcp/ip';
  dbxProps.CommunicationIPVersion := 'IPv6';
end;
Run Code Online (Sandbox Code Playgroud)

  • 你*应该*使用`TSQLConnection.Params`属性而不是直接类型转换`TSQLConnection.ConnectionData.Properties`。 (2认同)