I am trying to insert data from ASP.net webforms into SQL Server but I get an error
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
I don't understand this error, please help me find out what is what is this error.
Protected Sub Myinsert_Click(sender As Object, e As EventArgs) Handles Myinsert.Click
Dim dt As New Date
dt = DateAndTime.Now.ToString
p = "Image/" + ImgPath.FileName.ToString
Try
cn.Open()
cmd.Connection = cn
cmd.CommandText = "INSERT INTO MyWebSite( img, type, title, short_para, full_para, datepost) VALUES('" & p & "','" & txtType.Text & "','" & txtTitle.Text & "','" & ParaTT.Text & "','" & Para.Text & "','" & dt & "')"
cmd.ExecuteNonQuery()
cn.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub