Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15702

[RESOLVED] SQL Command adding Date parameter really DateTime

$
0
0
I have a MS SQL Server table with a column of type Date. My program has a variable of type "Date?" with a value of "0220-11-20". A typographical error from the source. My update query has a parameter for the value. When the command is executed I get "Update of Db failed. SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."
I've tried many things. I went down the rabbit hole about the DateTime being to narrow, but that's not it. I can update the column with that date value in a manual SQL query. I started to suspect the problem was in the adding parameter process. If I expand the parameter the value is correct, but the SQLValue is:
Quote:

SqlValue = '(New System.Collections.Generic.Mscorlib_CollectionDebugView(Of System.Data.SqlClient.SqlParameter)(comm.Parameters._items).Items(21)).SqlValue' threw an exception of type 'System.Data.SqlTypes.SqlTypeException'
.
I understand that Date is an alias for DateTime so I am guessing when I use the AddWithParameter it detects the variable as DateTime and tries to set the SQL Date value which of course is out of range.
Since there's no true Date type in VB.NET, how does one add a parameter as Date?

Viewing all articles
Browse latest Browse all 15702

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>