![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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,AccountInfoAct ive,AccountInfoHasDigiNotarKey,AccountInfoDigiNota rKeyIsStored,AccountInfoUsedSize,AccountInfoMaxVer sions,AccountTypeID,AccountInfoOwnerID,AccountInfo StartDate,AccountInfoDigiNotarKey,AccountInfoDigiN otarKeyHash,AccountInfoTrialUser,AccountInfoChange dBy,AccountInfoUserProfileTypeID) select UserInfoUserName,AccountInfoStatus,AccountInfoActi ve,AccountInfoHasDigiNotarKey,AccountInfoDigiNotar KeyIsStored,AccountInfoUsedSize,AccountInfoMaxVers ions,AccountTypeID,AccountInfoOwnerID,getdate(),Ac countInfoDigiNotarKey,AccountInfoDigiNotarKeyHash, AccountInfoTrialUser,AccountInfoChangedBy,AccountI nfoUserProfileTypeID from AccountInfo with (READUNCOMMITTED) where userinfousername=@0 |
#3
| |||
| |||
|
|
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 (AT) discussions (DOT) microsoft.com> wrote in message news:56D73326-6B9B-482A-9D76-55162DE6E1DB (AT) microsoft (DOT) com... 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,AccountInfoAct ive,AccountInfoHasDigiNotarKey,AccountInfoDigiNota rKeyIsStored,AccountInfoUsedSize,AccountInfoMaxVer sions,AccountTypeID,AccountInfoOwnerID,AccountInfo StartDate,AccountInfoDigiNotarKey,AccountInfoDigiN otarKeyHash,AccountInfoTrialUser,AccountInfoChange dBy,AccountInfoUserProfileTypeID) select UserInfoUserName,AccountInfoStatus,AccountInfoActi ve,AccountInfoHasDigiNotarKey,AccountInfoDigiNotar KeyIsStored,AccountInfoUsedSize,AccountInfoMaxVers ions,AccountTypeID,AccountInfoOwnerID,getdate(),Ac countInfoDigiNotarKey,AccountInfoDigiNotarKeyHash, AccountInfoTrialUser,AccountInfoChangedBy,AccountI nfoUserProfileTypeID from AccountInfo with (READUNCOMMITTED) where userinfousername=@0 |
![]() |
| Thread Tools | |
| Display Modes | |
| |