The simple guess is that the field is NULL and Delphi cannot convert this to
an integer ...
Myles.


-----Original Message-----
From: Mark Derricutt [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 26 July 2001 10:59 a.m.
To: Multiple recipients of list delphi
Subject: [DUG]: Variants and ActiveX and Delphi strangeness...


I have an odd problem here, I'm creating an ADO object via =
CreateOleObject
and everything there is sweet, but I'm having problems setting a class
variable (integer) to one of the fields.  Take the following code:

procedure TForm1.Button1Click(Sender: TObject);
var
  Conn, Rs: Variant;
  i: integer;
begin
  Conn :=3D AConn;

  Rs :=3D Conn.Execute(Format('SELECT * FROM Btimecontrol WHERE =
session_id =3D
''%s''',[ASessionID]));

  // Setup Session Properties
  i :=3D Rs.Fields['current_staff_ref'];
  FCurrentStaffRef :=3D Rs.Fields['current_staff_ref']; // =
FCurrentStaffRef is
define in the TForm1 public section
end;

The assignment to i works fine, but the assignment to FCurrentStaffRef =
fails
with an "invalid variant conversion", this is with delphi4, is any =
there any
reason why this would fail or am I doing something wrong?  It'll be =
annoying
if I have to assign a local variable each time, then set the class =
variable
to the local one...


-- 
Vi de udødelige inviterer dere til å slå dere sammen med oss

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to