Problem reading Timestamp columns again

Problem reading Timestamp columns again

Old forum URL: forums.lhotka.net/forums/t/8977.aspx


Jav posted on Monday, May 24, 2010

Few weeks ago I was having problems reading a timestamp value from the SafeDataReader.  Luckily, I was able to figure it out soon enough.  Now I am having a tough time getting the new timestamp value from an OUTPUT Command parameter. 

From the SafeDataReader I was able to do this:
            byte[] _lastmodif = new byte[ 8 ];
            dr.GetBytes("lastmodif", 0, _lastmodif, 0, 8);
            LoadProperty(lastmodifProperty, _lastmodif);

The .GetBytes appears to do the trick.

With the Command (OUTPUT) parameter I have tried this - among many other:
            _lastmodif = (byte[])(cm.Parameters["@NewLastModif"].Value);
But I keep getting runtime errors.

In VB I was always able to do this:
            mlastmodif = CType(cm.Parameters("@NewLastModif").Value, Byte())


Would appreciate a hint or two.  Needless to say, I have gone through almost every Csla demo and the Videos and the Csla C# book, but cannot find an example that shows Command Output parameter.

Jav

RedShiftZ replied on Monday, May 24, 2010

Jav,

I do it this way...

private byte[] _tStamp;

SqlParameter parmTStamp = new SqlParameter("@NewTStamp", SqlDbType.Timestamp);
parmTStamp.Direction = ParameterDirection.Output;
cmd.Parameters.Add(parmTStamp);

cmd.ExecuteNonQuery;

_tStamp = (byte[])parmTStamp.Value;

 

Jeff

 

 

 

Jav replied on Monday, May 24, 2010

Jeff,

You are absolutely correct.  I was not creating my OUTPUT parameter for the timestamp field correctly.  Since my VB code in a previous App was working fine, I went back to see what the difference was.  And there I was creating my OUTPUT parameter exactly as you have given. So everything is back on track now.  Thanks.

Copyright (c) Marimer LLC