Solved

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

Posted on 2006-10-24
7
1,146 Views
Last Modified: 2012-06-22
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
Comment
Question by:wimmeyvaert
  • 4
  • 2
7 Comments
 
LVL 28

Expert Comment

by:ciuly
ID: 17794322
try varnull
0
 
LVL 6

Author Comment

by:wimmeyvaert
ID: 17794346
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
 
LVL 6

Author Comment

by:wimmeyvaert
ID: 17794350
Found my solution on : http://www.martinstoeckli.ch/delphi/delphi.html
Section 'Variants and COM'
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 6

Author Comment

by:wimmeyvaert
ID: 17794414
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
 
LVL 28

Expert Comment

by:ciuly
ID: 17794419
> 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
 
LVL 6

Author Comment

by:wimmeyvaert
ID: 17795052
OK, thanks for the understanding.

I'll ask for a refund then.

Best regards and keep up the good work,

The Mayor.
0
 
LVL 1

Accepted Solution

by:
kodiakbear earned 0 total points
ID: 17800258
Closed, 50 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now