Re: SqlParameter of a SqlType
- From: "Val Mazur \(MVP\)" <group51a@xxxxxxxxxxx>
- Date: Wed, 20 Apr 2005 18:08:00 -0400
Hi,
I would not expect that Guid type should allow to accept NULL values. What
you could do is to set it to Nothing in a case if output parameter is NULL.
In this case you will keep result in one variable, but in a case of NULL it
will be set to Nothing
--
Val Mazur
Microsoft MVP
http://xport.mvps.org
"Aleksei" <aleksei.guzev@xxxxxxxxx> wrote in message
news:1113995160.707798.184240@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> 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: Aleksei
- Re: SqlParameter of a SqlType
- References:
- SqlParameter of a SqlType
- From: Aleksei
- SqlParameter of a SqlType
- Prev by Date: Re: trouble reading CSV file with Jet OLEDB
- Next by Date: RE: OdbcDataApdater in vs.net2003
- Previous by thread: SqlParameter of a SqlType
- Next by thread: Re: SqlParameter of a SqlType
- Index(es):