Re: Strange error while executing query
- From: Ekrem Önsoy <ekrem@xxxxxxxxxxxx>
- Date: Thu, 30 Aug 2007 01:06:25 +0300
Hello!
How about using a variable and assign "today.date" value to that variable in c# and use this variable as a parameter in your query code?
--
Ekrem Önsoy
"rvangeldrop" <rvangeldrop@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:56D73326-6B9B-482A-9D76-55162DE6E1DB@xxxxxxxxxxxxxxxx
Hi,
I have an unexpected error while executing the query below
If I run it in Management Studio it will work fine, but if I run it using my
code in C# on the same machine it will fail with the following exception:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999
11:59:59 PM
I use 'System.Data.SqlClient.SqlCommand' and execute the query using
'ExecuteNonQuery'.
It fails because it wants to insert getdate(). If I replace getdate() with
NULL it works. If I then run an extra update query using a parameter with the
correct date in it, this will work too. I do have systems however, that
accept the original query.
How can this be and how can make it work?
Query:
insert into accounthistory
(UserInfoUserName,AccountInfoStatus,AccountInfoActive,AccountInfoHasDigiNotarKey,AccountInfoDigiNotarKeyIsStored,AccountInfoUsedSize,AccountInfoMaxVersions,AccountTypeID,AccountInfoOwnerID,AccountInfoStartDate,AccountInfoDigiNotarKey,AccountInfoDigiNotarKeyHash,AccountInfoTrialUser,AccountInfoChangedBy,AccountInfoUserProfileTypeID)
select
UserInfoUserName,AccountInfoStatus,AccountInfoActive,AccountInfoHasDigiNotarKey,AccountInfoDigiNotarKeyIsStored,AccountInfoUsedSize,AccountInfoMaxVersions,AccountTypeID,AccountInfoOwnerID,getdate(),AccountInfoDigiNotarKey,AccountInfoDigiNotarKeyHash,AccountInfoTrialUser,AccountInfoChangedBy,AccountInfoUserProfileTypeID from AccountInfo with (READUNCOMMITTED) where userinfousername=@0
.
- Prev by Date: Re: ODBC error
- Next by Date: Re: Need tool (Enterprise manager?) on Vista to access SQL Server 2000
- Previous by thread: Re: ODBC error
- Next by thread: Re: Need tool (Enterprise manager?) on Vista to access SQL Server 2000
- Index(es):
Relevant Pages
|
Loading