PC Review


Reply
Thread Tools Rating: Thread Rating: 6 votes, 5.00 average.

nullable sqlparameter

 
 
buran
Guest
Posts: n/a
 
      17th Jul 2003
Dear ASP.NET Programmers,

How can I make an sqlparamater accept NULL value programmatically? I use the
following the code, but it does not work:

Dim admDate As SqlParameter
admDate = New SqlParameter("@admissionDate", SqlDbType.SmallDateTime)
admDate.isNullable = True
admDate.Value = CType(admissionDate, Date).Date.ToString("dd.MM.yyyy")

The compliler throws an exception when passing System.DBNull value to the
sqlparamater admDate.
Thanks in advance,

Buran


 
Reply With Quote
 
 
 
 
Frans Bouma
Guest
Posts: n/a
 
      17th Jul 2003
"buran" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> Dear ASP.NET Programmers,
>
> How can I make an sqlparamater accept NULL value programmatically? I use
> the following the code, but it does not work:
>
> Dim admDate As SqlParameter
> admDate = New SqlParameter("@admissionDate", SqlDbType.SmallDateTime)
> admDate.isNullable = True
> admDate.Value = CType(admissionDate, Date).Date.ToString("dd.MM.yyyy")
>
> The compliler throws an exception when passing System.DBNull value to
> the sqlparamater admDate.


if you do:
amdDate.Value = System.DBNull.Value

this throws an exception? Which one?

You can also pass: nothing, or simply do not pass a value, it will be NULL
automatically. (if my memory doesn't fool me )

FB

--
Solutions Design : http://www.sd.nl
My open source .NET Software : http://www.sd.nl/software
My .NET Blog : http://weblogs.asp.net/FBouma
-------------------------------------------------------------------------
 
Reply With Quote
 
 
 
 
buran
Guest
Posts: n/a
 
      17th Jul 2003
Thanks, that worked

"Frans Bouma" <(E-Mail Removed)> wrote in message
news:Xns93BB6BA5472CDperseusnewsxs4allnl@207.46.248.16...
> "buran" <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>
> > Dear ASP.NET Programmers,
> >
> > How can I make an sqlparamater accept NULL value programmatically? I use
> > the following the code, but it does not work:
> >
> > Dim admDate As SqlParameter
> > admDate = New SqlParameter("@admissionDate", SqlDbType.SmallDateTime)
> > admDate.isNullable = True
> > admDate.Value = CType(admissionDate, Date).Date.ToString("dd.MM.yyyy")
> >
> > The compliler throws an exception when passing System.DBNull value to
> > the sqlparamater admDate.

>
> if you do:
> amdDate.Value = System.DBNull.Value
>
> this throws an exception? Which one?
>
> You can also pass: nothing, or simply do not pass a value, it will be NULL
> automatically. (if my memory doesn't fool me )
>
> FB
>
> --
> Solutions Design : http://www.sd.nl
> My open source .NET Software : http://www.sd.nl/software
> My .NET Blog : http://weblogs.asp.net/FBouma
> -------------------------------------------------------------------------



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between nullable class and nullable<> structure Raj Microsoft C# .NET 31 19th Oct 2009 11:01 PM
Problem with SQLParameter data type (because 'System.Data.SqlClient.SqlParameter' is not derived from 'StoreBO.StoreBackOffice.SqlParameter'. ) Stacey Levine Microsoft VB .NET 3 16th Mar 2005 03:39 AM
nullable types. why no support for nullable string Sakoulakis Microsoft C# .NET 3 6th Aug 2004 03:41 PM
Converting to Type of SqlParameter Microsoft Dot NET Framework 0 17th Oct 2003 02:27 PM
nullable sqlparameter buran Microsoft ASP .NET 0 17th Jul 2003 09:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:47 AM.