I have the following form:
and what I need to do is to pass the value of ReturnValue into my second form, because this is a date range that I need to help present results to users. Right now form two is as follows:
So as you can see, its just a data set to be presented at the moment, but the return value in form one is needed to help specify data in form 2. Can anyone offer any help please.
Thank you
Doug
VB.NET:
Imports System.Data.SqlClient
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.YesNo)
If ButtonDialogResult = Windows.Forms.DialogResult.Yes Then
'pass 'Return Value' to SQL query that will be here'
Button2.Enabled = True
Button1.Enabled = False
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form2.Show()
End Sub
End Class
and what I need to do is to pass the value of ReturnValue into my second form, because this is a date range that I need to help present results to users. Right now form two is as follows:
VB.NET:
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'MDRDataSet2.Exceptions' table. You can move, or remove it, as needed.
Me.ExceptionsTableAdapter.Fill(Me.MDRDataSet2.Exceptions)
'TODO: This line of code loads data into the 'MDRDataSet1.mOpInterval' table. You can move, or remove it, as needed.
Me.MOpIntervalTableAdapter.Fill(Me.MDRDataSet1.mOpInterval)
'TODO: This line of code loads data into the 'MDRDataSet.Employees' table. You can move, or remove it, as needed.
Me.EmployeesTableAdapter.Fill(Me.MDRDataSet.Employees)
End Sub
Private Sub FillByToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillByToolStripButton.Click
Try
Me.ExceptionsTableAdapter.FillBy(Me.MDRDataSet2.Exceptions)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub FillBy1ToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillBy1ToolStripButton.Click
Try
Me.ExceptionsTableAdapter.FillBy1(Me.MDRDataSet2.Exceptions)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub FillByToolStrip_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles FillByToolStrip.ItemClicked
End Sub
End Class
So as you can see, its just a data set to be presented at the moment, but the return value in form one is needed to help specify data in form 2. Can anyone offer any help please.
Thank you
Doug