ADODB 连接到 firebird

ADODB connection to firebird

如何使用 ADODB 连接到 firebird 数据库? 我正在使用 testcomplete 来测试在 firebird 上运行的应用程序。 以下无效...

Conn = new ActiveXObject("ADODB.Connection");
constr = 'User=SYSDBA;Password=masterkey;Database=C:\..\Sample.fdb;DataSource=Local;Port=3050;Dialect=3;Charset=NONE;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0;'

Conn.ConnectionString = constr;
qrery = 'Select Count(*) FROM XX ';

recSet = new ActiveXObject("ADODB.Recordset");
recSet.Open(qrery,Conn,3 /* adOpenStatic */, 1 /* adLockReadOnly */,1);

Log.Message(recSet.Fields.Item(0).Value  );

recSet.Close();

出现以下错误

The connection cannot be used to perform this operation. It is either closed or invalid in this context

您需要在创建连接之后和进行查询之前打开连接:

  var Conn = new ActiveXObject("ADODB.Connection");
  var constr = 'User=SYSDBA;Password=masterkey;Database=C:\..\Sample.fdb;DataSource=Local;Port=3050;Dialect=3;Charset=NONE;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0;'

  Conn.ConnectionString = constr;
  var qrery = 'Select Count(*) FROM XX ';

  Conn.Open(); // Openning the connection

  var recSet = new ActiveXObject("ADODB.Recordset");
  recSet.Open(qrery,Conn,3 /* adOpenStatic */, 1 /* adLockReadOnly */,1);

  Log.Message(recSet.Fields.Item(0).Value  );

  recSet.Close();