Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert NULL with ADO from Delphi to SQL Server 2000

I am trying to insert data into a SQL Server 2000 database with the help of ADO in Delphi 2007.

So far I've written something like this:

insert into (a,b)
select :a,:b

qry.parameters.parambyname('a').value := '';
qry.parameters.parambyname('b').value := '';

The error I get is:

Disallowed implicit conversion from data type text to data type nvarchar...
use the convert function to run this query.

The columns in the table allow NULL values.

What I want is that the SQL Server table shows NULL where the value is ''. How can I achieve that?

like image 963
Joe Avatar asked Feb 17 '26 03:02

Joe


2 Answers

you can replace with theses lines

qry.parameters.parambyname('a').value := Null;
qry.parameters.parambyname('b').value := Null;
like image 184
Aghilas Yakoub Avatar answered Feb 18 '26 23:02

Aghilas Yakoub


qry.parameters.parambyname('a').value := unassigned;
like image 39
Kuba Wyrostek Avatar answered Feb 18 '26 23:02

Kuba Wyrostek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!