R
Robert Storrs
I am using the Microsoft Data Access Application Block
for .NET code to interface to our SQL database. I have a
stored procedure (CREATE procedure ixe_MarkBranchStatus
@NodeState int = 0, @rootnode uniqueidentifier = null).
I have the data for rootnode store as a string
representation of a GUID in my C# program. I use the
following code to supply the parameters:
*********************************************************
storedParams =
SqlHelperParameterCache.GetSpParameterSet
(connStr,SQL_Name);
for (int i = 0; i <
storedParams.Length; i++) {
switch
(storedParams.ParameterName.ToUpper()) {
case "@NODESTATE":
storedParams.Value = newStatus;
break;
case "@ROOTNODE":
storedParams.Value = GUID;
break;
}
}
if
(SqlHelper.ExecuteNonQuery
(connStr,CommandType.StoredProcedure,SQL_Name,storedParams)
***********************************************************
The SQLHelper (Microsoft supplied code) bubbles up an
error: Invalid cast from System.String to System.Guid.
The line that causes the error is:
int retval = cmd.ExecuteNonQuery();
but a lot has gone on before this.
This was not a problem until I recently converted from
VS .NET, framework 1.0 to VS 2003, framework 1.1
for .NET code to interface to our SQL database. I have a
stored procedure (CREATE procedure ixe_MarkBranchStatus
@NodeState int = 0, @rootnode uniqueidentifier = null).
I have the data for rootnode store as a string
representation of a GUID in my C# program. I use the
following code to supply the parameters:
*********************************************************
storedParams =
SqlHelperParameterCache.GetSpParameterSet
(connStr,SQL_Name);
for (int i = 0; i <
storedParams.Length; i++) {
switch
(storedParams.ParameterName.ToUpper()) {
case "@NODESTATE":
storedParams.Value = newStatus;
break;
case "@ROOTNODE":
storedParams.Value = GUID;
break;
}
}
if
(SqlHelper.ExecuteNonQuery
(connStr,CommandType.StoredProcedure,SQL_Name,storedParams)
0) return true;
***********************************************************
The SQLHelper (Microsoft supplied code) bubbles up an
error: Invalid cast from System.String to System.Guid.
The line that causes the error is:
int retval = cmd.ExecuteNonQuery();
but a lot has gone on before this.
This was not a problem until I recently converted from
VS .NET, framework 1.0 to VS 2003, framework 1.1