Re: Pass dbNull to SmallDateTime field
From: Alastair Williamson (alastair.williamson_at_tiso.co.uk)
Date: 09/27/04
- Next message: Mark: "ODBC & OLEDB"
- Previous message: Steven Cheng[MSFT]: "Re: Datatable's Select and Compute methods"
- In reply to: Ibrahim Shameeque: "RE: Pass dbNull to SmallDateTime field"
- Messages sorted by: [ date ] [ thread ]
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
> >
> >
> >
- Next message: Mark: "ODBC & OLEDB"
- Previous message: Steven Cheng[MSFT]: "Re: Datatable's Select and Compute methods"
- In reply to: Ibrahim Shameeque: "RE: Pass dbNull to SmallDateTime field"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|