.NET Parameter Direction affects datatype casting

D

Davide

Hi

We have a stored procedure for inserting data into a
table and another for Updating that table.

For the Insert SP we use a LastModifiedDateTime output
parameter and for the Update SP we use the InputOutput
parameter direction.

When we execute the query the following line works for
the Insert:
_lastModifiedDateTime = (DateTime)cmdToExecute.Parameter­
(e-mail address removed);

But for the execution for the Update we need to use:
_lastModifiedDateTime = (sqlDatetime)cmdToExecute.Parame­
(e-mail address removed);

When checking the datavalue we have noticed that if we
use input or inputoutput as the parameter direction it
returns sqlDateTime as the datatye but when we use the
Ouput parameter direction it returns DateTime as the
datatype.

The lines we use are:
cmdToExecute.Parameters.Add(new ­ SqlParameter
("@daLastModifiedDat­ eTime", SqlDbType.DateTime, 8,
ParameterDirection.InputOutput, ­ true, 23, 3, "",
DataRowVersion.Proposed, _lastModifiedDateTime));

cmdToExecute.Parameters.Add(new ­ SqlParameter
("@daLastModifiedDat­ eTime", SqlDbType.DateTime, 8,
ParameterDirection.Output, true, 23, 3, "",
DataRowVersion.Proposed, _lastModifiedDateTime));

Is this the correct behaviour?
Is there something I am missing from
cmdToExecute.Parameters statments?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top