Ver Mensaje Individual
  #27  
Antiguo 10-12-2014
orodriguezca orodriguezca is offline
Miembro
 
Registrado: ene 2009
Posts: 221
Reputación: 16
orodriguezca Va por buen camino
Aquí no funciona correctamente RecordCount

Código Delphi [-]
program Project10;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  adodb,
  db,
  ActiveX;

var
  Conn: TAdoConnection;
  AdoQuery1: TAdoQuery;
begin
  CoInitialize(nil);
  try
    Conn := TAdoConnection.Create(nil);
    try
      conn.ConnectionString :=
        'Provider=SQLNCLI10.1;' +
        'Integrated Security=SSPI;' +
        'Persist Security Info=False;' +
        'User ID="";' +
        'Initial Catalog=SELA;' +
        'Data Source=MyDireccionIP;' +
        'Initial File Name="";' +
        'Server SPN=""';
      conn.Open();

      AdoQuery1 := TAdoQuery.Create(nil);
      try
        AdoQuery1.Connection := Conn;
        AdoQuery1.CursorLocation := clUseServer;
        AdoQuery1.CursorType := ctOpenForwardOnly;

        AdoQuery1.SQL.Text := 'select * from PARAMETROS';
        AdoQuery1.Open;
        WriteLn('Numero de registros: ', AdoQuery1.RecordCount);
        //AdoQuery1.RecordCount restorna -1 en SQL Server.
        // en DB2 for i retorna 0
        AdoQuery1.Close;
      finally
        AdoQuery1.Free;
      end;

    finally
      Conn.Free;
    end;
    ReadLn;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
Responder Con Cita