Please help how can i convert and send this date well
thanks in advance error produced
Server Error in '/' Application.
Conversion failed when converting date and/or time from character string.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Conversion failed when converting date and/or time from character string.
Source Error:
Line 35: cmd.Parameters.Add("@dates", SqlDbType.DateTime).Value = Convert.ToDateTime(Dates.Text).ToString
Line 36: con.Open()
Line 37: cmd.ExecuteNonQuery()
Line 38: con.Close()
Line 39: End Using
Source File: C:\Users\Makumbi\source\repos\INTERVIEWSVB\INTERVIEWSVB\Forms\Payments.aspx.vb Line: 37
Stack Trace:
[SqlException (0x80131904): Conversion failed when converting date and/or time from character string.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +2582954
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6034042
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +297
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4291
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) +262
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +2698
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +1611
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +390
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +297
INTERVIEWSVB.Payments.Button1_Click(Object sender, EventArgs e) in C:\Users\Makumbi\source\repos\INTERVIEWSVB\INTERVIEWSVB\Forms\Payments.aspx.vb:37
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9796242
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +211
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1696
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4465.0
Code
Dim constr As String = ConfigurationManager.ConnectionStrings("INTERVIEWSConnectionString").ConnectionString
Using con As New SqlConnection(constr)
Dim query As String = "insert into Commitfee values (@Names, @admno, @class,@amount,@Description,@rtpno,@dates)"
Using cmd As New SqlCommand(query)
cmd.Connection = con
cmd.Parameters.Add("@Names", SqlDbType.VarChar).Value = StudentNames.Text
cmd.Parameters.Add("@admno", SqlDbType.NVarChar).Value = admno.Text
cmd.Parameters.Add("@class", SqlDbType.NVarChar).Value = Classr.Text
cmd.Parameters.Add("@amount", SqlDbType.NVarChar).Value = amount.Text
cmd.Parameters.Add("@Description", SqlDbType.VarChar).Value = Descrption.Text
cmd.Parameters.Add("@rtpno", SqlDbType.NVarChar).Value = Rcpt.Text
'Dim idatefro As String = DateTime.Parse(Dates.Text).ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)
cmd.Parameters.Add("@dates", SqlDbType.DateTime).Value = Convert.ToDateTime(Dates.Text).ToString
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
End Using