Board index » delphi » SQL Server Stored Proc Null Date

SQL Server Stored Proc Null Date

Hello,

Using Delphi 6.0 ent ADO Stored proc with SQL Server 7.0.

How do I make a date null?

Example:

with spNames do begin
    parameters[1].value := strLastName;
    parameters[2].value := strFirstName;
    if isDate(strRegDate) then    {function that verifies good date}
        parameters[3].value := strToDate(strRegDate)
    else
        parameters[3].value := 'null';    {<---- ERROR!  Application uses a
value of the wrong type for the current operation}

    ExecProc;
end;

I've tried '' and nil and just about evertything else but always get the
same error.

Huge thanks in advance!
Craig

 

Re:SQL Server Stored Proc Null Date


Tried it and it doesn't work.  The "clear" is on the whole parameter list,
i.e., spNames.clear; but spNames.parameters[3].clear; won't even compile.
Clearing the whold parameter list has proven to be a bad thing, as a list
out of index error happens first thing.

Thanks for the tip, tho.

Craig

"Brian Jones (Adroit Software)" <bri...@adroit-software.co.uk> wrote in
message news:3dbf9281$1@newsgroups.borland.com...

Quote
> Have you tried parameters[3].clear ?

> "Craig" <cr...@radicalage.com> wrote in message
> news:3dbef87d@newsgroups.borland.com...
> > Hello,

> > Using Delphi 6.0 ent ADO Stored proc with SQL Server 7.0.

> > How do I make a date null?

> > Example:

> > with spNames do begin
> >     parameters[1].value := strLastName;
> >     parameters[2].value := strFirstName;
> >     if isDate(strRegDate) then    {function that verifies good date}
> >         parameters[3].value := strToDate(strRegDate)
> >     else
> >         parameters[3].value := 'null';    {<---- ERROR!  Application
uses
> a
> > value of the wrong type for the current operation}

> >     ExecProc;
> > end;

> > I've tried '' and nil and just about evertything else but always get the
> > same error.

> > Huge thanks in advance!
> > Craig

Re:SQL Server Stored Proc Null Date


Have you tried...

parameters[3].value := NULL;

NULL is defined in System.pas

Quote
"Craig" <cr...@radicalage.com> wrote in message

news:3dc01f64@newsgroups.borland.com...
Quote
> Tried it and it doesn't work.  The "clear" is on the whole parameter list,
> i.e., spNames.clear; but spNames.parameters[3].clear; won't even compile.
> Clearing the whold parameter list has proven to be a bad thing, as a list
> out of index error happens first thing.

> Thanks for the tip, tho.

> Craig

> "Brian Jones (Adroit Software)" <bri...@adroit-software.co.uk> wrote in
> message news:3dbf9281$1@newsgroups.borland.com...
> > Have you tried parameters[3].clear ?

> > "Craig" <cr...@radicalage.com> wrote in message
> > news:3dbef87d@newsgroups.borland.com...
> > > Hello,

> > > Using Delphi 6.0 ent ADO Stored proc with SQL Server 7.0.

> > > How do I make a date null?

> > > Example:

> > > with spNames do begin
> > >     parameters[1].value := strLastName;
> > >     parameters[2].value := strFirstName;
> > >     if isDate(strRegDate) then    {function that verifies good date}
> > >         parameters[3].value := strToDate(strRegDate)
> > >     else
> > >         parameters[3].value := 'null';    {<---- ERROR!  Application
> uses
> > a
> > > value of the wrong type for the current operation}

> > >     ExecProc;
> > > end;

> > > I've tried '' and nil and just about evertything else but always get
the
> > > same error.

> > > Huge thanks in advance!
> > > Craig

Re:SQL Server Stored Proc Null Date


rb,

That did the trick!  Thanks!

Craig

Quote
"rb" <raj...@killspam-sympatico.ca> wrote in message

news:3dc0f3b1$1@newsgroups.borland.com...
Quote

> "Craig" <cr...@radicalage.com> wrote in message
> news:3dc01f64@newsgroups.borland.com...
> > Tried it and it doesn't work.  The "clear" is on the whole parameter
> list,
> > i.e., spNames.clear; but spNames.parameters[3].clear; won't even
compile.

> Try with Parameters.ParamValues[ 'name' ] := Unassigned; {add Variants to
> uses}

> rb

Other Threads