SQL DateTime v VB.NET Date

xiecsuk

Member
Joined
Apr 24, 2005
Messages
23
Location
Coventry, Warwickshire, UK
Programming Experience
10+
I have a variable declared as Date in VB.NET. I have a field declared as DateTime in an SQL table. I just cannot seem to SELECT, INSERT or UPDATE the field without getting a "System Error". I have tried CAST to try and convert the variable as I read or write it, without any luck. I have resorted to using a string field in SQL and DateValue in VB.NET until I can sort it out.

Can anybody tell me how to maintain the DateTime field type in SQL and how to CAST the variable properly.
 
In A previous Project i used this code i was using a SP accept the data as a parameter the code was like that
VB.NET:
 With PR5
.ParameterName = "@EndDate"
.SourceColumn = "EndDate"
.SqlDbType = SqlDbType.DateTime
.Direction = ParameterDirection.Input
.Value = DateTimePicker2.Value.ToShortDateString
End With

the most vital part here was
VB.NET:
.Value = DateTimePicker2.Value.ToShortDateString
i hope it helps
 
Back
Top