Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1222
  • Last Modified:

Assign Nil-Value to a TADOStoredProc-Parameter ...

Hi,

Environment:
  - Delphi 5 Enterprise Edition on Windows XP machines.
  - SQL Server 2000 (on Windows 2000).



I wonder if there is a way to explicitly set the value of a Stored Procedure Parameter to a NULL (NIL) Value from code.

So it should be something like :
spMyStoredProc.Parameters.ParamByName('Param1').Value := nil; // Does not compile !!

Then I get compilation-error : incompatible type Variant and Pointer.

Anybody any idea how to solve/work around this problem ?

Best regards,

The Mayor.
0
wimmeyvaert
Asked:
wimmeyvaert
  • 4
  • 2
1 Solution
 
2266180Commented:
try varnull
0
 
wimmeyvaertAuthor Commented:
Does'nt seem to work.

BUT !!!!!

I found a solution myself :

spMyStoredProc.Parameters.ParamByName('Param1').Value := UnAssigned;

Simple as that !!

Is it for you OK if I ask EE to refund my points ?
0
 
wimmeyvaertAuthor Commented:
Found my solution on : http://www.martinstoeckli.ch/delphi/delphi.html
Section 'Variants and COM'
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
wimmeyvaertAuthor Commented:
I tried following possibilities :

spMyStoredProc.Parameters.ParamByName('Param1').Value := varNull; //-> NOK
spMyStoredProc.Parameters.ParamByName('Param1').Value := varEmpty; // -> NOK
spMyStoredProc.Parameters.ParamByName('Param1').Value := UnAssigned; // -> OK !

So, the only working possibility in my case is to use 'UnAssigned'.
0
 
2266180Commented:
> Is it for you OK if I ask EE to refund my points ?
it is very ok. it is actually the thing to do when you find the answer yourself ;)
0
 
wimmeyvaertAuthor Commented:
OK, thanks for the understanding.

I'll ask for a refund then.

Best regards and keep up the good work,

The Mayor.
0
 
kodiakbearCommented:
Closed, 50 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now