No, I'm just trying to take a date (mm/dd/yy) entered into a textbox and
assign it to a sqldatetime field.
> Scott: Are you trying to set parameter values to the datetime? If so, try
> cmd.Parameters.Add("@FirstParam", SqlDbType.DateTime).Value =
[quoted text clipped - 22 lines]
> > System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store
> > <9/10/2003 12:00:00 PM> in EventDate Column. Expected type is DateTime.
William Ryan eMVP - 21 Mar 2004 05:26 GMT
? How are you doing this assignment? How's it getting back to the database
for the assignment?
> No, I'm just trying to take a date (mm/dd/yy) entered into a textbox and
> assign it to a sqldatetime field.
[quoted text clipped - 28 lines]
> store
> > > <9/10/2003 12:00:00 PM> in EventDate Column. Expected type is DateTime.
Scott M. - 22 Mar 2004 18:34 GMT
Ok, I've got you now William. Thanks. That did the trick!
> ? How are you doing this assignment? How's it getting back to the database
> for the assignment?
[quoted text clipped - 32 lines]
> > > > <9/10/2003 12:00:00 PM> in EventDate Column. Expected type is
> DateTime.
Cor - 21 Mar 2004 10:11 GMT
Hi Scott,
Have a look at this, be aware that I have cut some sentences away, so there
can be errors but you get the idea with this.
AddHandler b(i).Format, AddressOf DBdateTextbox
AddHandler b(i).Parse, AddressOf TextBoxDBdate
I use a table to enum the textboxes so I have to do it only once for all
date textboxes.
(And this is for the European date format)
I hope this helps?
Cor
\\\
Private Sub DBdateTextbox(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = DirectCast(cevent.Value, Date)
cevent.Value = datum.ToString("dd - MM - yyyy")
End If
End Sub
Private Sub TextBoxDBdate(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value.ToString = "" Then
cevent.Value = DBNull.Value
End If
End Sub
///
Cor - 21 Mar 2004 10:16 GMT
Hi Scott,
Now I see you are not using databinding, this sample is with databinding,
but maybe you can use it anyhow.
Cor