SqlParameter of a SqlType
- From: "Aleksei" <aleksei.guzev@xxxxxxxxx>
- Date: 20 Apr 2005 04:06:00 -0700
SqlParameter converts the value to a CLR type. But this is a problem
while storing OUTPUT parameter values to CLR variable of a type from
System.Data.SqlTypes namespace. For example, the following obviously
does not work
SqlParameter p = new SqlParameter ("@id",SqlDbType.UniqueIdentifier);
SqlGuid id = (SqlGuid) p.Value;
Replacing the second line helps
SqlGuid id;
if (p.Value is DBNull) id=SqlGuid.Null;
else id.Value=(Guid) p.Value;
But this solution implies two conversions and the performance gain
(noted in MSDN library, "System.Data.SqlTypes") could not be achieved.
Using CLR type System.Guid instead of System.Data.SqlTypes.SqlGuid
denies accepting DBNull values.
Is there any way to get SqlType from a SqlParameter directly? Maybe I
have missed something?
Aleksei
.
- Follow-Ups:
- Re: SqlParameter of a SqlType
- From: Gabriel Lozano-Morán
- Re: SqlParameter of a SqlType
- From: Val Mazur \(MVP\)
- Re: SqlParameter of a SqlType
- Prev by Date: Re: Too long Record in Insert by OleDb (Ms Access)
- Next by Date: Re: Generic data transfer
- Previous by thread: How to detect changes
- Next by thread: Re: SqlParameter of a SqlType
- Index(es):