Joost van der Sluis schreef:
The error is probably handled somewhere, so you can't see it. But when
you run it in the debugger, it shows the exception.
But I need more information so I can help you, can you sow some code?
'send a string value' doesn't explain t me what you're doing.
On Thu, 2006-12-14 at 21:36 +0100, Koenraad Lelong wrote:
Hi,
For my first real Lazarus application I'm using the IBConnection stuff
to pump some legacy stuff to Firebird/Interbase. When I send a string
value to a varchar-field I get an exception : EVariantTypecastError, but
only in the IDE. From the commandline everything works fine.
Any hints were things could go wrong ?
I'm using the release version of Lazarus 2.0.4.
Regards,
Koenraad Lelong.
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives
I made a test-program. This is how I made the table in Firebird 2.0 :
Create Table ibtest (
StringField Varchar(20)
);
This is the code I used to test :
unit frmTest1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
IBConnection, sqldb, Buttons;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
IBConnection1: TIBConnection;
SQLQuery1: TSQLQuery;
SQLTransaction1: TSQLTransaction;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
var
i : integer;
procedure TForm1.FormCreate(Sender: TObject);
begin
IBConnection1.HostName:='Localhost';
IBConnection1.DatabaseName:='/home/koenraad/fpc/firebird/ibtest.fdb';
IBConnection1.Open;
SQLQuery1.SQL.Clear;
SQLQuery1.SQL.Add('select * from ibtest;');
SQLQuery1.InsertSQL.Clear;
SQLQuery1.InsertSQL.Add('INSERT INTO IBTEST (STRINGFIELD)');
SQLQuery1.InsertSQL.Add('VALUES (:STRINGFIELD)');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if SQLQuery1.Active then
SQLQuery1.Close;
IBConnection1.Close;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if not SQLTransaction1.Active then
SQLTransaction1.StartTransaction;
if not SQLQuery1.Active then
SQLQuery1.Open;
for i:=1 to 100 do
begin
SQLQuery1.Append;
SQLQuery1.FieldByName('STRINGFIELD').Value:='String'+IntToStr(i);
SQLQuery1.ApplyUpdates;
SQLTransaction1.CommitRetaining;
end;
end;
initialization
{$I frmtest1.lrs}
end.
The error I get :
Project raised exception class 'EVariantTypeCastError' with message :
Could not convert variant of type (String) into type (OleStr)
And then the line "SQLQuery1.ApplyUpdates;" is highlighted.
I was curious and modified the table from varchar to char, with the same
result. In this test I commit after every record and they appear in the
table. In my original program, I did the commit after all records (a few
thousands) and I stopped the program after a few error-messages. That's
why I didn't see anything in the database.
I see I didn't say I'm running Linux.
I hope you can shed some light,
Regards,
Koenraad Lelong.
P.S. If you drop a second IBConnection (for another database) on the
form and connect it, you can't quit the program without a segfault.
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives