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 

Exception

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Johny
Guest





PostPosted: Tue Aug 26, 2003 9:56 pm    Post subject: Exception Reply with 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



Back to top
Robert MacLean
Guest





PostPosted: Wed Aug 27, 2003 6:29 am    Post subject: Re: Exception Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) 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.