JoelFan
JoelFan

Reputation: 38714

Why is there an underscore in the type name _Recordset?

I have code which queries a database, like this:

uses Data.DB, Data.Win.ADODB;

// ...

var
  cmd: TAdoCommand;
  r: _Recordset;
  firstName: string;

begin
  cmd := TAdoCommand.Create(nil);
  try
    cmd.ConnectionString := 'Server=dbServer;Database=master';
    cmd.CommandText := 'select FirstName from customers where id=123';
    r := cmd.Execute;
    firstName := '';
    if not r.EOF then firstName := r.Fields.Item['FirstName'].Value
  finally
    cmd.Free
  end

  // ...
end

This works but I'm wondering if it's not the ideal way to write it, because of the underscore at the beginning of the _Recordset type. It seems like the underscore is telling me that this type is "internal" in some way and not to be used in standard code.

Is there a more standard way to write this kind of code? If not, why is the underscore there?

Upvotes: 1

Views: 108

Answers (1)

fpiette
fpiette

Reputation: 12292

If you add Winapi.ADOInt to the use clause, you can remove the underscore and use RecordSet.

This is because in Data.Win.ADODB we have:

 _Recordset = Winapi.ADOInt.Recordset;

and in Winapi.ADOInt we have:

Recordset = _Recordset;
_Recordset = interface(Recordset21)

Upvotes: 2

Related Questions