| View previous topic :: View next topic |
| Author |
Message |
Johny Guest
|
Posted: Tue Aug 26, 2003 9:56 pm Post subject: Exception |
|
|
When I try this from application:
adodsCh.Close();
adodsCh.CommandText="spA_GetKForCheck '" +
IntToStr((int)year) + "." + IntToStr((int)month) + "." +
IntToStr((int)day) +
"'"
;
adodsCh.Open();
I get exception:
"The conversion of a char data type to a datetime data type resulted in an
out-of-range datetime value"
but for example if I put same call on execute it on query analyzer on SQL
server(spA_GetKForCheck '2003.1.26')
I get good result without any error.
Why I get exception from Borland.
This is store procedure which I call:
CREATE PROCEDURE spA_GetKForCheck
(
@sdater varchar(20)
)
AS
SELECT MAX(KID) AS KID FROM BKv WHERE (ValidFromDate < @sdater) AND
(ValidToDate > @sdater)
GO
|
|
| Back to top |
|
 |
Robert MacLean Guest
|
Posted: Wed Aug 27, 2003 6:29 am Post subject: Re: Exception |
|
|
Johny (goky2002 (AT) beograd (DOT) com) moved some electrons around and created
the following:
| Quote: | When I try this from application:
adodsCh.Close();
adodsCh.CommandText="spA_GetKForCheck '" +
IntToStr((int)year) + "." + IntToStr((int)month) + "." +
IntToStr((int)day) +
"'"
;
adodsCh.Open();
I get exception:
"The conversion of a char data type to a datetime data type resulted
in an out-of-range datetime value"
but for example if I put same call on execute it on query analyzer on
SQL server(spA_GetKForCheck '2003.1.26')
I get good result without any error.
Why I get exception from Borland.
This is store procedure which I call:
CREATE PROCEDURE spA_GetKForCheck
(
@sdater varchar(20)
)
AS
SELECT MAX(KID) AS KID FROM BKv WHERE (ValidFromDate < @sdater) AND
(ValidToDate > @sdater)
GO
|
that exception is coming from the sql server, not from delphi. most likely the
reason query analyser does not give the error is because it does the
conversation automatically.
it means that sql server does not like the format you are using.
have a look at SET DATEFORMAT in the sql online docs and put that into your
stored proc.
there was also a post in this group a few days back titles "set dateformat
problem" which dealt with the same sort of issue.
--
___________________________________________
Robert MacLean
robert at sadev dot co dot za
Web: http://www.sadev.co.za
|
|
| Back to top |
|
 |
|