Expand|Select|Wrap|Line Numbers
- Private Sub Exceptionquery()
- Dim connection As System.Data.SqlClient.SqlConnection
- Dim connectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx"
- Dim _sql As String = "SELECT [Exceptions].Employeenumber,[Exceptions].exceptiondate, [Exceptions].starttime, [exceptions].endtime, [Exceptions].code, datediff(minute, starttime, endtime) as duration INTO scratchpad3 " + _
- "FROM [Exceptions]" + _
- "where [Exceptions].exceptiondate between @payperiodstartdate and payperiodenddate" + _
- "GROUP BY [Exceptions].Employeenumber, [Exceptions].Exceptiondate, [Exceptions].starttime, [exceptions].endtime," + _
- "[Exceptions].code, [Exceptions].exceptiondate"
- connection = New SqlConnection(connectionString)
- connection.Open()
- Dim _CMD As SqlCommand = New SqlCommand(_sql, connection)
- _CMD.Parameters.AddWithValue("@payperiodstartdate", payperiodstartdate)
- _CMD.Parameters.AddWithValue("@payperiodenddate", payperiodenddate)
- connection.Close()
- End Sub
- Public Sub exceptionsButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exceptionsButton.Click
- Exceptionquery()
- Dim connection As System.Data.SqlClient.SqlConnection
- Dim adapter As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter
- Dim connectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx"
- Dim ds As New DataSet
- Dim _sql As String = "SELECT * from scratchpad3"
- connection = New SqlConnection(connectionString)
- connection.Open()
- Dim _CMD As SqlCommand = New SqlCommand(_sql, connection)
- _CMD.Parameters.AddWithValue("@payperiodstartdate", payperiodstartdate)
- _CMD.Parameters.AddWithValue("@payperiodenddate", payperiodenddate)
- adapter.SelectCommand = _CMD
- Try
- adapter.Fill(ds)
- If ds Is Nothing OrElse ds.Tables.Count = 0 OrElse ds.Tables(0).Rows.Count = 0 Then
- 'it's empty
- MessageBox.Show("There was no data for this time period. Press Ok to continue", "No Data")
- connection.Close()
- Exceptions.saveButton.Enabled = False
- Exceptions.Show()
- Else
- connection.Close()
- Exceptions.Show()
- End If
- Catch ex As Exception
- MessageBox.Show(ex.ToString)
- connection.Close()
- End Try
- End Sub
Expand|Select|Wrap|Line Numbers
- Public Sub exceptionsButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exceptionsButton.Click
Expand|Select|Wrap|Line Numbers
- adapter.Fill(ds)
Expand|Select|Wrap|Line Numbers
- Exceptionquery()
Thank you
Doug