How to pass string indexes for OleVariant

I'm converting the following example code to Delphi:

http://msdn.microsoft.com/en-us/library/bb176406%28v=office.12%29.aspx

My code is something like:

var
  vTable, vRow: OleVariant;
begin
....

  while vTable.EndOfTable = False do
  begin
    vRow := vTable.GetNextRow;
    sEmail := vRow['Email1Address'];
    ShowMessage(sEmail);
  end;
end;

The problem is that I need to pass a string index, 'Email1Address', but Delphi gives the error: Incompatible types: Integer and string.

Should I be using a different type of variant?

TIA

Answers


I've taken a look at the Outlook unit generated from a TLB file and it looks like this:

_Row = interface(IDispatch)
    ['{000630D3-0000-0000-C000-000000000046}']
    //snip
    function Item(Index: OleVariant): OleVariant; safecall;
    //snip
  end;

The Row interface has a method Item, which takes an OleVariant. So use this:

sEmail := vRow.Item('Email1Address');

Also take a look at the MSDN help.


Need Your Help

Purpose of using projections in vertica database

database database-design data-warehouse vertica

I have a vertica database that using projections. I read vertica docs but docs generally talk about how to issue;

Is it possible to set spring security session expiration by age?

spring-security session-timeout

I am trying to get a spring security session to expire after 30 minutes from log in. I do not want the timeBeforeExperation to be reset after every interaction.