I have a web page in which there is a textbox that asks my users to enter a start date. What I'm trying to do from there is that no matter what the end date is, my page will calculated that from the text box, store it as a variable and pass it to my stored procedure. Here is the page I have so far:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles wasoncallButton.Click
Dim ds As New DataSet
Dim dt As New DataTable
Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
Dim newDate As DateTime
Dim connectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx"
Dim con As New SqlConnection(connectionString)
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "sp_owncalls3"
cmd.Parameters.AddWithValue("@start", dateTextBox.Text)
Try
If newDate.Date.AddDays(1).AddSeconds(-1).ToString() Then
cmd.Parameters.AddWithValue("@dayend", newDate)
Else
errorlabel.Text = "Invalid Date"
End If
Catch ex As Exception
Response.Write("Error:" & ex.ToString)
End Try
End Sub
End Class
The two variables here are @start and @dayend. @start will be gathered from the text box, but I need to know how to calculate and save the variable for @dayend. Any help would be appreciated.
Thank you,
Doug