Thank you.
On Jan 24, 11:13 am, "rowe_newsgroups" <rowe_em...@yahoo.comwrote:
If not, please try to explain what you are looking for a little better
and we'll try to help.
I'm struggling with dates and ado. I have a sub that will be used to
update both strings and date fields in a table, and so I want the
field name in question to be dynamic. So the field type might be string
or datetime. I'm trying to avoid overloading the sub if possible. The
string update logic works fine, but I try to use it for dates I get
this error:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and
12/31/9999 11:59:59 PM.
here's the sub:
Public Sub UpdateJob(ByVal Jobno As Integer, ByVal field As String,
ByVal Value As Object)
...
SQL = "Update job set " + field + "= @datef where jobno =
@jobno"
cmd.Parameters.Add("@datef", SqlDbType.DateTime).Value =
CType(Value, DateTime)
...
Dim numrow As Integer = cmd.ExecuteNonQuery
when it fails, the sub is called as follows
UpdateJob(jobno, datef) ... where datef is a datetime field I got
back from a stored proceddure output.
datef resolves to :2007-01-24 11:15:06.000 and when I do this manually
Update job set enddate='2007-01-24 11:15:06.000' where jobno = 2
it works.
but if I datef.tostring I get some string with AM / PM which does not
work.
and want to see the exact SQL that is being attempted.