My environment is as follows:
LLBLGen Pro v2.0.0.0 Final (March 19th, 2007)
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll v2.0.7.319
Adapter + .NET v2.0
SQL Server 2005 Express
I have an action procedure in my project that calls the following stored procedure.
CREATE PROCEDURE [dbo].[GetServerDateTime]
@ServerDateTime datetime output
AS
BEGIN
SET NOCOUNT ON;
SET @ServerDateTime = GETDATE();
END
GO
If I call this procedure in my application as follows it works fine, correctly returning the database server time.
DateTime serverDateTime = new DateTime(2007, 1, 1);
ActionProcedures.GetServerDateTime(ref serverDateTime);
If, however, I change the initialisation of the variable to the following, it fails.
DateTime serverDateTime = new DateTime();
ActionProcedures.GetServerDateTime(ref serverDateTime);
The exception is as follows.
System.Data.SqlTypes.SqlTypeException was unhandled
Message="SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."
Source="System.Data"
StackTrace:
at System.Data.SqlTypes.SqlDateTime.FromTimeSpan(TimeSpan value)
at System.Data.SqlTypes.SqlDateTime.FromDateTime(DateTime value)
at System.Data.SqlTypes.SqlDateTime..ctor(DateTime value)
at System.Data.SqlClient.MetaType.FromDateTime(DateTime dateTime, Byte cb)
at System.Data.SqlClient.TdsParser.WriteValue(Object value, MetaType type, Int32 actualLength, Int32 encodingByteSize, Int32 offset, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at RinkerAustralia.TDS.Workflow.DAL.DatabaseSpecific.DataAccessAdapter.CallActionStoredProcedure(String storedProcedureToCall, SqlParameter[] parameters) in D:\Work\Workflow\DAL\DatabaseSpecific\DataAccessAdapter.cs:line 192
at RinkerAustralia.TDS.Workflow.DAL.DatabaseSpecific.ActionProcedures.GetServerDateTime(DateTime& serverDateTime, DataAccessAdapter adapter) in D:\Work\Workflow\DAL\DatabaseSpecific\ActionProcedures.cs:line 61
at RinkerAustralia.TDS.Workflow.DAL.DatabaseSpecific.ActionProcedures.GetServerDateTime(DateTime& serverDateTime) in D:\Work\Workflow\DAL\DatabaseSpecific\ActionProcedures.cs:line 44
... etc
Is this a bug?
It seems in the second case that it doesn't even try to call the stored procedure. It's like it validates the parameter value before calling the procedure, finds it in error, and returns. I can't confirm whether it calls the procedure or not as there is no sign of it in the DQE trace regardless of whether it succeeds or fails.
Any help would be appreciated.
Regards,
Bruce