BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TSQLQuery & Date fields

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress)
View previous topic :: View next topic  
Author Message
Angel Torrecillas de Pedr
Guest





PostPosted: Wed Jan 28, 2004 9:44 am    Post subject: TSQLQuery & Date fields Reply with 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
Harald Feigel
Guest





PostPosted: Wed Jan 28, 2004 8:43 pm    Post subject: Re: TSQLQuery & Date fields Reply with quote



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





PostPosted: Fri Jan 30, 2004 8:29 pm    Post subject: Re: TSQLQuery & Date fields Reply with 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
Angel Torrecillas de Pedr
Guest





PostPosted: Mon Feb 02, 2004 12:02 pm    Post subject: Re: TSQLQuery & Date fields Reply with 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...
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





PostPosted: Sat Feb 07, 2004 9:27 pm    Post subject: Re: TSQLQuery & Date fields Reply with 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

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





PostPosted: Sun Feb 08, 2004 3:18 pm    Post subject: Re: TSQLQuery & Date fields Reply with quote

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





PostPosted: Thu Feb 12, 2004 11:55 am    Post subject: Re: TSQLQuery & Date fields Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.