Discussion:
'Could not convert variant of type (Null) into type (String)'
(too old to reply)
Kura
2006-01-13 10:34:01 UTC
Permalink
In borland C++ builder 6 I add ADOTable and set up
ConnectionString on value:
Provider=MSDASQL.1;Password=masterkey;Persist Security Info=True;User
ID=sysdba;Data Source=ConnectFbServer;Mode=ReadWrite


I connecting with Firebird, I have OLE DB driver from
Firebird website.


In propertise for ADOTable "table name" I choose my table,and set active on
true
When i compiling the program i get an exception:
Project "Name.exe" raised exception class EVariantTypeCastError with
message 'Could not convert variant of type (Null) into type (String)'.


I don`t have any others components then Form and ADOTable.

I'll be greatfull for any suggestions.(Sory for my Englisch!)
Mike Shkolnik
2006-01-13 14:02:02 UTC
Permalink
Somewhere in your code you read the Value property for field and applied to
AnsiString variable.
Just use the AsString for your field instead Value and no error will be
raised

--
With best regards, Mike Shkolnik
EMail: ***@scalabium.com
http://www.scalabium.com
Post by Kura
In borland C++ builder 6 I add ADOTable and set up
Provider=MSDASQL.1;Password=masterkey;Persist Security Info=True;User
ID=sysdba;Data Source=ConnectFbServer;Mode=ReadWrite
I connecting with Firebird, I have OLE DB driver from
Firebird website.
In propertise for ADOTable "table name" I choose my table,and set active on
true
Project "Name.exe" raised exception class EVariantTypeCastError with
message 'Could not convert variant of type (Null) into type (String)'.
I don`t have any others components then Form and ADOTable.
I'll be greatfull for any suggestions.(Sory for my Englisch!)
Kura
2006-01-13 14:12:20 UTC
Permalink
The point is , that I haven`t any code. I just put component ADOTable on
empty form, and use "Build" button in window of property "ConnectionString"
to create connection atributes.
????
Post by Mike Shkolnik
Somewhere in your code you read the Value property for field and applied to
AnsiString variable.
Just use the AsString for your field instead Value and no error will be
raised
--
With best regards, Mike Shkolnik
http://www.scalabium.com
Vladimir Stefanovic
2006-01-13 14:19:21 UTC
Permalink
Add *all* the tabels' fields to the header.

How?

Double click on every (design time) TADOTable icon you have,
and then a small window will appear. Then, find a way to:
"Add all filelds..." (or something similar).

BUILD ALL.

P.S.

Please let us know if that works...
--
Best regards,
Vladimir Stefanovic
Kura
2006-01-13 16:41:17 UTC
Permalink
Thanks a lot. It`s works.Thank you, thank you, thank you;-).
Now I have next question about it.What`s the name of property where i adding
all fields from my table(just like tou say)?How I can do it from application
code?Any function or somethink?
Once again thanks awfull!
Post by Vladimir Stefanovic
Add *all* the tabels' fields to the header.
How?
Double click on every (design time) TADOTable icon you have,
"Add all filelds..." (or something similar).
BUILD ALL.
P.S.
Please let us know if that works...
Vladimir Stefanovic
2006-01-13 17:04:36 UTC
Permalink
Post by Kura
Thanks a lot. It`s works.Thank you, thank you,
thank you;-).
Great :)
Post by Kura
What`s the name of property where i adding all fields
from my table(just like tou say)?
Sorry, can you be more speciffic?

(You just add the fields at design-time, and you do not need
anything else with them at run-time)

In fact you can make an app without adding those fields at all
but you may experience some difficulties, as you already noticed.
Post by Kura
How I can do it from application code?Any function or
somethink?
Why do you need that?

I suppose that you can do something like this:

--- example from BCB6 help (for SQLDataSet, but must be the
similar for ADO) ---

SQLDataSet1->Close();

TFloatField *T = new TFloatField(SQLDataSet1);
T->Precision = 2;
T->FieldName = "Amount";
T->Name = SQLDataSet1->Name + T->FieldName;
T->Index = SQLDataSet1->FieldCount;
T->DataSet = SQLDataSet1;
SQLDataSet1->FieldDefs->UpDate();
SQLDataSet1->Open();

But yiu do not need that at all.
--
Best regards,
Vladimir Stefanovic
Continue reading on narkive:
Loading...