My application allows you to import content from an Excel file into a DataGridView, with the aim of then sending to save all the contents to a BD, one of the columns is date type but with the format "MM / dd / yyyy" , that date before sending it to the BD I enter it in a variable of type string
, what I want is to change the format to "dd / MM / yyyy" and send it to the BD with that format, the code I use It is as follows:
Dim fecha As String = ""
fecha = fila.Cells("F1").Value
Dim formato As String = ""
formato = Format(CDate(fecha), "dd/MM/yyyy")
agregar.Parameters.AddWithValue("@fecha", Convert.ToDateTime(formato))
The error is sent to me when evaluating the date "09/13/2017"