I have the following code:
and as you can see, I am showing users the next available date open to them is determined with the value dteReturnValue.ToShortDateString .. but what I'd like to do is show the user both the start date and the end date, which will always be +7 days from the field in my database. Can someone offer me a way to show this date, thank you.
Doug
VB.NET:
Public Class Form1
Dim ReturnValue As Object = Nothing
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connectionString As String
Dim cnn As SqlConnection
Dim myCommand As SqlCommand
Dim dteReturnValue As DateTime = Nothing
'the connection string to the SQL server'
connectionString = "Data Source=10.2.1.41;Initial Catalog=MDR;uid=xxxxx;password=xxxxx"
cnn = New SqlConnection(connectionString)
cnn.Open()
'the SQL query'
Try
myCommand = New SqlCommand("select payrolldate from payroll where payrolldate <= getdate ()")
myCommand.Connection = cnn
ReturnValue = myCommand.ExecuteScalar()
If ReturnValue IsNot Nothing Then
dteReturnValue = Convert.ToDateTime(ReturnValue)
dteReturnValue = dteReturnValue.AddDays(1)
End If
Catch exp As SqlException
End Try
cnn.Close()
Dim ButtonDialogResult As DialogResult
ButtonDialogResult = MessageBox.Show(String.Format("The next date available to you is {0}", dteReturnValue.ToShortDateString()), "Payroll", MessageBoxButtons.OK)
If ButtonDialogResult = Windows.Forms.DialogResult.OK Then
'pass 'Return Value' to SQL query that will be here'
Button2.Enabled = True
Button1.Enabled = False
End If
End Sub
and as you can see, I am showing users the next available date open to them is determined with the value dteReturnValue.ToShortDateString .. but what I'd like to do is show the user both the start date and the end date, which will always be +7 days from the field in my database. Can someone offer me a way to show this date, thank you.
Doug