I need a datatype (or enum?) that can hold the possible values: true/
false/null
I will use it in ADO.NET code like:
sqlCmd.Parameters.Add("@isApproved", SqlDbType.Bit, 1).Value = ?????;
This way I can pass values of true,false or null to my stored
procedure.
Is there a way to do this or do I have to do things like :
if(myEnum != MyEnum.NULL)
sqlCmd.Parameters.Add("@isApproved", SqlDbType.Bit, 1).Value =
myEnum;
> I need a datatype (or enum?) that can hold the possible values:
> true/false/null
> I will use it in ADO.NET code like:
> sqlCmd.Parameters.Add("@isApproved", SqlDbType.Bit, 1).Value = ?????;
> This way I can pass values of true,false or null to my stored
> procedure.
I think you should be able to use SqlBoolean from System.Data.SqlTypes.
Eq.
>Hi,
>
>I need a datatype (or enum?) that can hold the possible values: true/
>false/null
Nullable types may be just what you're looking for:
http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx
Regards,
Gilles.
Does that work?
Ok, I confess, I am too lazy to try so I will ask… would this work
even if the sql parameter requires DBNull.Value?
Is passing null to an sql parameter equivalent to passing
DBNull.Value?
Thanks.
On May 15, 3:57 pm, "Gilles Kohl [MVP]" <no_email_available@> wrote:
> On Thu, 15 May 2008 13:01:57 -0700 (PDT), DotNetNewbie
>
[TestFixture]
public class Test
{
[Test]
public void NullDBNullEqual()
{
Assert.AreEqual(null, DBNull.Value);
}
}
Joachim
I realize that DBNull.Value and null are not equal, that wasn’t the
question.
What I was interested in knowing is if the Value property of the SQL
parameter (SqlParameter) object will internally treat DBNull.Value and
null as being the same thing.
This is really no big deal, I was just curious.
On May 16, 2:39 am, Joachim Van den Bogaert <joac...@yamagata-