G
gozza
Hi,
I had a look at MSDN and it clearly sais that SqlGuid can be casted as Guid.
To execute a stored procedure I have the following function (note the s.proc
does not return any recordsets, just sets the output value):
function updateEntry(ref System.Guid valueID, ...){
...
cmd.ExecuteNonQuery();
//get the output value now:
valueID = (System.Guid)cmd.Parameters["@valueID"].Value;
....
}
Please note that the valueID is passed by reference. The code works fine
if I don't pass a value (i.e. set the parameter to DBNull): the valueID gets
set as expected. The problem occurs when I do pass a value. I get an
Invalid Cast exception?!
If I use the following sequence for getting the valueID, the code works
fine, but as you can guess, it seems a bit too much:
....
//get the output value now:
object o = cmd.Parameters["@valueID"].Value;
valueID = new Guid(o.ToString());
...
Any ideas what I am missing in the first version?
Thanks,
Goran
I had a look at MSDN and it clearly sais that SqlGuid can be casted as Guid.
To execute a stored procedure I have the following function (note the s.proc
does not return any recordsets, just sets the output value):
function updateEntry(ref System.Guid valueID, ...){
...
cmd.ExecuteNonQuery();
//get the output value now:
valueID = (System.Guid)cmd.Parameters["@valueID"].Value;
....
}
Please note that the valueID is passed by reference. The code works fine
if I don't pass a value (i.e. set the parameter to DBNull): the valueID gets
set as expected. The problem occurs when I do pass a value. I get an
Invalid Cast exception?!
If I use the following sequence for getting the valueID, the code works
fine, but as you can guess, it seems a bit too much:
....
//get the output value now:
object o = cmd.Parameters["@valueID"].Value;
valueID = new Guid(o.ToString());
...
Any ideas what I am missing in the first version?
Thanks,
Goran