• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1236
  • 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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