Board index » delphi » error assigning NULL to a TSQLDataSet parameter - dbExpress (Error msg: No value for parameter FldDate)

error assigning NULL to a TSQLDataSet parameter - dbExpress (Error msg: No value for parameter FldDate)

How can I assign a NULL value to TSQLDataSet parameter?

I tried to use this
. . .
SQLDataSet1.CommandText := 'insert into Arquivo (FldInt, FldStr, FldDate)
values (:FldInt, :FldStr, :FldDate)'
SQLDataSet1.ParamByName('FldInt').value := 15;
SQLDataSet1.ParamByName('FldStr').value := 'TEST';
SQLDataSet1.ParamByName('FldDate').value := NULL;             // Error here
. . .

With ADO this work, but with dbExpress a get this msg:
    No value for parameter FldDate

I already tried this:
  SQLDataSet1.ParamByName('FldDate').Clear;

--
Thanks in advance,
Alvaro L. S. Almeida

 

Re:error assigning NULL to a TSQLDataSet parameter - dbExpress (Error msg: No value for parameter FldDate)


SQLDataSet1.ParamByName('FldDate').Clear;

--
Bill
(TeamB cannot answer questions received via email)

Re:error assigning NULL to a TSQLDataSet parameter - dbExpress (Error msg: No value for parameter FldDate)


"Bill Todd (TeamB)" <bill.nos...@dbginc.com> wrote in message
news:3bd1e2c3$1_2@dnews...

Quote
> SQLDataSet1.ParamByName('FldDate').Clear;

> --
> Bill
> (TeamB cannot answer questions received via email)

If I try this I get the msg:  No value for parameter "FldDate"

I'm using D6.01 with IB6.01 and dbExpress (TSQLDataSet).

--
Alvaro L. S. Almeida

Re:error assigning NULL to a TSQLDataSet parameter - dbExpress (Error msg: No value for parameter FldDate)


I am not sure what the source of that error is. Does the field allow nulls?

--
Bill
(TeamB cannot answer questions received via email)

Re:error assigning NULL to a TSQLDataSet parameter - dbExpress (Error msg: No value for parameter FldDate)


Yes, the field allow nulls. I already tested with another field types, and
the error is the same (No value for parameter "XXX").

I'm using Delphi 6.01 Pro  with  INTERBASE 6.0.1

This is the table:
CREATE TABLE "TestTbl"
(  
  "FldInt"     INTEGER NOT NULL,
  "FldStr"     VARCHAR(50) CHARACTER SET WIN1252 COLLATE PXW_INTL850,
  "FldDate"  DATE
);

for insert, I'm using
  SQLDataSet1.CommandText := 'insert into TesTbl (FldInt, FldStr, FldDate) values (:FldInt, :FldStr, :FldDate)';

but I can't pass a NULL value to any parameter.

I already tested these:
  SQLDataSet1.ParamByName('FldDate').Clear;
  SQLDataSet1.ParamByName('FldDate').AsString := '';
  SQLDataSet1.ParamByName('FldDate').value := NULL;
  SQLDataSet1.ParamByName('FldDate').AsDate := NULL;
 . . .

Using IBX or ADO (with SqlServer), I can assign NULL to any parameter, but with dbExpress, I can't!

--
Alvaro L. S. Almeida

Re:error assigning NULL to a TSQLDataSet parameter - dbExpress (Error msg: No value for parameter FldDate)


On Sat, 20 Oct 2001 17:53:57 -0300, "Alvaro L. S. Almeida"

Quote
<alvar...@centroin.com.br> wrote:
>"Bill Todd (TeamB)" <bill.nos...@dbginc.com> wrote in message
>news:3bd1e2c3$1_2@dnews...
>> SQLDataSet1.ParamByName('FldDate').Clear;

>> --
>> Bill
>> (TeamB cannot answer questions received via email)

>If I try this I get the msg:  No value for parameter "FldDate"

>I'm using D6.01 with IB6.01 and dbExpress (TSQLDataSet).

Try the following

SQLDataset1.ParamByName('FldDate').asDate:=date;
SQLDataset1.ParamByName('FldDate').Clear;

(Syntax not tested) As I Remember from working with the BDE, one has
to set some additional Info for the Parameter and the Assignment of a
Dummy-Value takes care of that. Then clearing the Parameter sets it to
NULL, but keeps the other Parameters (like fieldtype and so on)

HTH
Georg

Quote

>--
>Alvaro L. S. Almeida

Re:error assigning NULL to a TSQLDataSet parameter - dbExpress (Error msg: No value for parameter FldDate)


Great!
It works!

--
Thanks,
Alvaro L. S. Almeida
Droid Informatica
http://www.droidinfo.com

Quote
"Georg Stegmller" <gs...@sbox.tu-graz.ac.at> wrote in message

news:3bd7e0ba.7725158@newsgroups.borland.com...
Quote
> On Sat, 20 Oct 2001 17:53:57 -0300, "Alvaro L. S. Almeida"
> <alvar...@centroin.com.br> wrote:

> >"Bill Todd (TeamB)" <bill.nos...@dbginc.com> wrote in message
> >news:3bd1e2c3$1_2@dnews...
> >> SQLDataSet1.ParamByName('FldDate').Clear;

> >> --
> >> Bill
> >> (TeamB cannot answer questions received via email)

> >If I try this I get the msg:  No value for parameter "FldDate"

> >I'm using D6.01 with IB6.01 and dbExpress (TSQLDataSet).

> Try the following

> SQLDataset1.ParamByName('FldDate').asDate:=date;
> SQLDataset1.ParamByName('FldDate').Clear;

> (Syntax not tested) As I Remember from working with the BDE, one has
> to set some additional Info for the Parameter and the Assignment of a
> Dummy-Value takes care of that. Then clearing the Parameter sets it to
> NULL, but keeps the other Parameters (like fieldtype and so on)

> HTH
> Georg

> >--
> >Alvaro L. S. Almeida

Other Threads