Re: Pass dbNull to SmallDateTime field

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Alastair Williamson (alastair.williamson_at_tiso.co.uk)
Date: 09/27/04


Date: Mon, 27 Sep 2004 09:34:52 +0100

Thanks, but I'd already tried that one and it returns an error too!

Cheers

C-Ya Aly

"Ibrahim Shameeque" <IbrahimShameeque@discussions.microsoft.com> wrote in
message news:0D1C335E-6EA3-4483-B8FF-37663B9EB3D6@microsoft.com...
> Hi
> try
> nCmd.Parameters.Add("@DateReq",dbnull.value)
> Thanks
> "Alastair Williamson" wrote:
>
> > Hi there,
> >
> > I'm feeling kind of stupid that I can't work this one out for myself and
I
> > hope someone can point me in the right direction.
> >
> > I have an insert command that puts a selected Date into a smalldatetime
> > field in SQL Server 2000 (app is written in VB.NET vs2003). The
situation
> > now exists that I need to insert a Null value into the field and I can't
get
> > it to work. This is the code:
> >
> >
> > Dim nCmd as new SqlCommand("",nConn)
> > nCmd.CommandText = "INSERT INTO reps ([Reference],[DateRequired])
> > VALUES(@Reference,@DateReq)"
> > nCmd.Parameters.Add("@Reference",txtReference.Text)
> > If DateReq = True Then
> > nCmd.Parameters.Add("@DateReq",dtpDateReq.Value.Date)
> > Else
> > 'Don't know what to put here!!!!
> > End IF
> > nCmd.ExecuteNonQuery()
> >
> >
> > If I pass a blank value it puts 1900.01.01 in the field. Can anyone tell
me
> > how to get a Null value into the field.
> >
> > Many thanks
> >
> > C-Ya Aly
> >
> >
> >



Relevant Pages

  • Re: file search fails
    ... I guess you just like to state the obvious and treat everyone else as if they are stupid, rather try to do something useful. ... we've had to go back to using the DIR command because Vista's search missed so many files. ... MS elites upon which the lowly user may not tread), and the realm of the 'User', and not to venture where you're not supposed to. ...
    (microsoft.public.windows.vista.general)
  • Re: Re: Ruby/Tk: How to access surrounding class from Tk Callback?
    ... # Do something with @root and @foo ... puts @root.foo # DOES NOT WORK ... @root in your button's command is an instance variable ...
    (comp.lang.ruby)
  • Re: Why do we need Unions?
    ... > If unions are so great, why doesn't everyone beg to enlist in ... and was awarded "Television Equipment Repairman" which meant I ... was unfit for combat, so that kind of blows away, "Are you stupid? ... you really think command gives a rats ass whether you live or die in the ...
    (rec.crafts.metalworking)
  • Re: Mike Release the "nsh" command under the CDDL
    ... >>Since vim is a stupid ... >>command, it cannot tell me that in a critical area such as memory allocation, ... > At least, vim works as advertised, something that cannot be ...
    (comp.unix.solaris)
  • Re: Net::SSH expect like interface
    ... This is something I've been wanting for a long time too, ideally to use ssh ... passing in nil as the command name. ... puts s.cmd ... @channel = connection.open_channel( ...
    (comp.lang.ruby)