Private Sub CmbSelector_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbSelector.SelectedIndexChanged
Select Case cmbSelector.Text
Case "Количество поданных заявлений по отделениям" ' Первый CASE
Debug.Print(cmbSelector.Text)
dtBegin = CStr(dtpBegin.Value) & " " & cmbHBegin.Text & ":" & cmbMBegin.Text 'Присвоение значения переменным
dtEnd = CStr(dtpEnd.Value) & " " & cmbHEnd.Text & ":" & cmbMEnd.Text 'dtBegin и dtEnd
Debug.Print(dtBegin)
Debug.Print(dtEnd)
'Dim strSql As String
Dim DT As New Data.DataTable
Dim DS As New DataSet
Dim strSql As Odbc.OdbcCommand = New Odbc.OdbcCommand("select distinct" &
" subdivisionname , count(subdivisionname)" &
" from casehistories where createtime between '" & dtBegin & "' and '" & dtEnd & "'" &
" and operation =0 and subdivisionname <> ''" &
" group by subdivisionname order by count(subdivisionname)", cn) With {
.CommandType = CommandType.Text
}
' MsgBox("connected!!!")
Dim Sdap As Odbc.OdbcDataAdapter = New Odbc.OdbcDataAdapter With {
.SelectCommand = strSql
}
DS.Tables.Add(DT)
Sdap.Fill(DT)
DataGridView1.DataSource = (DT)
cn.Close()
Case "Общий отчет" 'Второй CASE
Debug.Print(cmbSelector.Text)
Dim DT As New Data.DataTable
Dim DS As New DataSet
Dim strSql As Odbc.OdbcCommand = New Odbc.OdbcCommand("SELECT DISTINCT" &
" documentcases.registrationdate , documentcases.documentcaseno, customers_naturalcustomer.lastname, customers_naturalcustomer.firstname" &
" From documentcases,customers_naturalcustomer" &
" Where documentcases.registrationdate Between '" & dtBegin & "' and '" & dtEnd & "'and customers_naturalcustomer.id = documentcases.customerid order by documentcases.registrationdate", cn)
'Переменные dtBegin и dtEnd пустые!!!!!?
DS.Tables.Add(DT)
Call New Odbc.OdbcDataAdapter() With {
.SelectCommand = strSql
}.Fill(DT)
DataGridView1.DataSource = (DT)
cn.Close()
End Select
End Sub