I am writing something in VB and need to convert a SQL date (not datetime) into a string. This should be an easy convertion, however toString does not work and I cannot find anything online . The part of the code I'm working on looks like this:
Dim incomingDate As String
incomingDate = row.Cells(5).Text.ToString()
When the data being put in the gridview is a DateTime datatype this works fine. If it's simply Date, it gives me the following error message:
"Specified argument was out of the range of valid values. Parameter name: index"
I've also tried this work-around but it didn't work
Dim incomingDate As String
Dim d As New DateTime
d = DateTime.Parse(row.Cells(5).Text)
incomingDate = Date.Parse(row.Cells(5).Text)
Same error...
row.Cells(5)doesn't exist. Do you have six columns? Remember to index the cells starting with 0, not 1. Other than that, retrieving the text via the.Textproperty should be ok. No need to parse into a Date unless you want to change the format.