Retrieving timestamp output parameter from SqlCommand

D

David Clegg

I've got a SqlCommand that executes a SQL Server 2000 stored procedure
which, among other things, returns a timestamp output parameter.

For the life of me, I can't figure out how to assign the value of this
timestamp value to a byte array. I figure it's gotta be simple so what
am I missing here?

--
Cheers,
David Clegg
dclegg_at_ebetonline_dot_com

Vote 1 http://cc.borland.com/codecentral/ccweb.exe/listing?id=21489 :)
Now supports Google Groups searching with Dyna-extend(tm) technology!

Quality Central. The best way to bug Borland about bugs.
http://qc.borland.com

"Oh, well, of course, everything looks bad if you remember it." - Homer
Simpson
 
M

Miha Markic [MVP C#]

Hi David,

byte[] bb = (byte[])sqlCommand1.Parameters[1].Value;

Does this work (assuming Parameters[1] is timestamp)?
 
D

David Clegg

Miha said:
byte[] bb = (byte[])sqlCommand1.Parameters[1].Value;

Does this work (assuming Parameters[1] is timestamp)?

Nope. System.InvalidCastException is thrown.

--
Cheers,
David Clegg
dclegg_at_ebetonline_dot_com

Vote 1 http://cc.borland.com/codecentral/ccweb.exe/listing?id=21489 :)
Now supports Google Groups searching with Dyna-extend(tm) technology!

Quality Central. The best way to bug Borland about bugs.
http://qc.borland.com

"Ahhh... sweet pity. Where would my love life be without it?" - Homer
Simpson
 
M

Miha Markic [MVP C#]

Hi David,

How exactly is your timestamp SqlParameter defined?
Is it int32 perhaps?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

David Clegg said:
Miha said:
byte[] bb = (byte[])sqlCommand1.Parameters[1].Value;

Does this work (assuming Parameters[1] is timestamp)?

Nope. System.InvalidCastException is thrown.

--
Cheers,
David Clegg
dclegg_at_ebetonline_dot_com

Vote 1 http://cc.borland.com/codecentral/ccweb.exe/listing?id=21489 :)
Now supports Google Groups searching with Dyna-extend(tm) technology!

Quality Central. The best way to bug Borland about bugs.
http://qc.borland.com

"Ahhh... sweet pity. Where would my love life be without it?" - Homer
Simpson
 
D

David Clegg

Miha said:
How exactly is your timestamp SqlParameter defined?
Is it int32 perhaps?

<Blush>
Yes that was it. The param was defined as SqlDbType.Int. Changing it to
SqlDbType.Timestamp fixed the problem.

I knew it would be something stupidly obvious. And as usual in these
situations it takes a second pair of eyes to see the mistake. Thanks
for your help.

--
Cheers,
David Clegg
dclegg_at_ebetonline_dot_com

Vote 1 http://cc.borland.com/codecentral/ccweb.exe/listing?id=21489 :)
Now supports Google Groups searching with Dyna-extend(tm) technology!

Quality Central. The best way to bug Borland about bugs.
http://qc.borland.com

"You never know when an old calendar might come in handy! Sure, it's
not 1985 right now, but who knows what tomorrow will bring?" - Homer
Simpson
 

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

Top