| View previous topic :: View next topic |
| Author |
Message |
Angel Torrecillas de Pedr Guest
|
Posted: Wed Jan 28, 2004 9:44 am Post subject: TSQLQuery & Date fields |
|
|
Hi
I have an application that connects to a SQLServer database through
dbExpress. I have a TSQLQuery with an insert statement that has some
parameters. If I assign a datetime value to the parameter of a datetime
field, the statement works fine, but if I want to assign a null value to
this parameter, the statement raise an exception saying that the value of
the parameter is not valid. I try different ways to do this, but the result
was the same:
- TSQLQuery.ParamByName('Date_param').Value := null
- TSQLQuery.ParamByName('Date_param').AsString := ''
- TSQLQuery.ParamByName('Date_param').AsSQLTimeStamp :=
NullSQLTimeStamp;
- TSQLQuery.ParamByName('Date_param').Clear;
How Can I do it? Any ideas?
Thaks in advance
|
|
| Back to top |
|
 |
Harald Feigel Guest
|
Posted: Wed Jan 28, 2004 8:43 pm Post subject: Re: TSQLQuery & Date fields |
|
|
Hi,
if you want to assign a NULL value to any of your parameters, regardless if
SQLTimeStamp or String or whatsoever, you will also have to specifiy:
TSQLQuery.ParamByName('Date_param').Bound := TRUE;
Have a look at that property in your online help. There is a good
description.
Harry
"Angel Torrecillas de Pedro" <angel (AT) egaraset (DOT) com> schrieb im Newsbeitrag
news:4017847b (AT) newsgroups (DOT) borland.com...
| Quote: | Hi
I have an application that connects to a SQLServer database through
dbExpress. I have a TSQLQuery with an insert statement that has some
parameters. If I assign a datetime value to the parameter of a datetime
field, the statement works fine, but if I want to assign a null value to
this parameter, the statement raise an exception saying that the value of
the parameter is not valid. I try different ways to do this, but the
result
was the same:
- TSQLQuery.ParamByName('Date_param').Value := null
- TSQLQuery.ParamByName('Date_param').AsString := ''
- TSQLQuery.ParamByName('Date_param').AsSQLTimeStamp :=
NullSQLTimeStamp;
- TSQLQuery.ParamByName('Date_param').Clear;
How Can I do it? Any ideas?
Thaks in advance
|
|
|
| Back to top |
|
 |
Roberto Novakosky Guest
|
Posted: Fri Jan 30, 2004 8:29 pm Post subject: Re: TSQLQuery & Date fields |
|
|
I already saw this problem:
I used bound too:
//...
TSQLQuery.ParamByName('MyParam').Clear
TSQLQuery.ParamByName('MyParam').Bound := TRUE;
//...
Or clearing visual DBEdit (without display seted).
Other solution is to delete the param and to create it again.
If someone know other solution i would like to know too.
:-)
Roberto Novakosky
São Paulo - Brazil
|
|
| Back to top |
|
 |
Angel Torrecillas de Pedr Guest
|
Posted: Mon Feb 02, 2004 12:02 pm Post subject: Re: TSQLQuery & Date fields |
|
|
I try to set the Bound property to True, but when I call the ExecSQL method,
the same error appear: "No value for parameter 'MyParam'"....
I don't know what more can I do to assign a null to this parameter...I don't
understand what is wrong...
thanks also
"Roberto Novakosky" <rnovak (AT) ig (DOT) com.br> escribió en el mensaje
news:401ABEA4.4090506 (AT) ig (DOT) com.br...
| Quote: | I already saw this problem:
I used bound too:
//...
TSQLQuery.ParamByName('MyParam').Clear
TSQLQuery.ParamByName('MyParam').Bound := TRUE;
//...
Or clearing visual DBEdit (without display seted).
Other solution is to delete the param and to create it again.
If someone know other solution i would like to know too.
:-)
Roberto Novakosky
São Paulo - Brazil
|
|
|
| Back to top |
|
 |
A Pham Guest
|
Posted: Sat Feb 07, 2004 9:27 pm Post subject: Re: TSQLQuery & Date fields |
|
|
try this
TSQLQuery.ParamByName('Date_param').Clear;
TSQLQuery.ParamByName('Date_param').Bound := True
TSQLQuery.ParamByName('Date_param').DataType := ftDate;
Cheers
A Pham
"Angel Torrecillas de Pedro" <angel (AT) egaraset (DOT) com> wrote
| Quote: | Hi
I have an application that connects to a SQLServer database through
dbExpress. I have a TSQLQuery with an insert statement that has some
parameters. If I assign a datetime value to the parameter of a datetime
field, the statement works fine, but if I want to assign a null value to
this parameter, the statement raise an exception saying that the value of
the parameter is not valid. I try different ways to do this, but the
result
was the same:
- TSQLQuery.ParamByName('Date_param').Value := null
- TSQLQuery.ParamByName('Date_param').AsString := ''
- TSQLQuery.ParamByName('Date_param').AsSQLTimeStamp :=
NullSQLTimeStamp;
- TSQLQuery.ParamByName('Date_param').Clear;
How Can I do it? Any ideas?
Thaks in advance
|
|
|
| Back to top |
|
 |
Roberto Novakosky Guest
|
Posted: Sun Feb 08, 2004 3:18 pm Post subject: Re: TSQLQuery & Date fields |
|
|
Try it
If Delhi 3: At Design time go to the Params(object Inspector) |The
option "null" must be checked to accept null values.
If delhpi 7: At Design Time go to the Params(object inspector) | choose
the param, open a level on +Value, set the type to "NULL" (the default
is unassigned).
I don't know if it resolves your problem, but try.
Angel Torrecillas de Pedro escreveu:
| Quote: | I try to set the Bound property to True, but when I call the ExecSQL method,
the same error appear: "No value for parameter 'MyParam'"....
I don't know what more can I do to assign a null to this parameter...I don't
understand what is wrong...
thanks also
"Roberto Novakosky" <rnovak (AT) ig (DOT) com.br> escribió en el mensaje
news:401ABEA4.4090506 (AT) ig (DOT) com.br...
I already saw this problem:
I used bound too:
//...
TSQLQuery.ParamByName('MyParam').Clear
TSQLQuery.ParamByName('MyParam').Bound := TRUE;
//...
Or clearing visual DBEdit (without display seted).
Other solution is to delete the param and to create it again.
If someone know other solution i would like to know too.
Roberto Novakosky
São Paulo - Brazil
|
|
|
| Back to top |
|
 |
Angel Torrecillas de Pedr Guest
|
Posted: Thu Feb 12, 2004 11:55 am Post subject: Re: TSQLQuery & Date fields |
|
|
This is the solution!!
It's necesarry to set the datatype property too!!!
Thank you very much!
"A Pham" <apz28 (AT) hotmail (DOT) com> escribió en el mensaje
news:40255494$1 (AT) newsgroups (DOT) borland.com...
| Quote: | try this
TSQLQuery.ParamByName('Date_param').Clear;
TSQLQuery.ParamByName('Date_param').Bound := True
TSQLQuery.ParamByName('Date_param').DataType := ftDate;
Cheers
A Pham
"Angel Torrecillas de Pedro" <angel (AT) egaraset (DOT) com> wrote in message
news:4017847b (AT) newsgroups (DOT) borland.com...
Hi
I have an application that connects to a SQLServer database through
dbExpress. I have a TSQLQuery with an insert statement that has some
parameters. If I assign a datetime value to the parameter of a datetime
field, the statement works fine, but if I want to assign a null value to
this parameter, the statement raise an exception saying that the value
of
the parameter is not valid. I try different ways to do this, but the
result
was the same:
- TSQLQuery.ParamByName('Date_param').Value := null
- TSQLQuery.ParamByName('Date_param').AsString := ''
- TSQLQuery.ParamByName('Date_param').AsSQLTimeStamp :=
NullSQLTimeStamp;
- TSQLQuery.ParamByName('Date_param').Clear;
How Can I do it? Any ideas?
Thaks in advance
|
|
|
| Back to top |
|
 |
|