Dim myDr As MySqlDataReader
Dim myDrEr As MySqlDataReader
Dim erRow As Integer = 0
If objConn.State = ConnectionState.Open Then
objConn.Close()
End If
Try
objConn.ConnectionString = strConn
objConn.Open()
Catch
MessageBox.Show("ไม่สารมารถติดต่อฐานข้อมูลได้กรุณาติดต่อผู้ดูแลระบบ")
End
End Try
strSQL = "select hn from opddata where dep1 = '021' AND left(icd10,1)<>'Z' and rdate between ('" & beginD & "') and ('" & endD & "') GROUP BY hn HAVING COUNT(hn) >1 order by hn "
myCom = New MySqlCommand(strSQL, objConn)
myDr = myCom.ExecuteReader
While myDr.Read
strSql1 = "select hn, rdate, name, icd10, icdName1 from opddata " & _
" where hn = '" & myDr("hn") & "' and dep1 = '021' AND left(icd10,1)<>'Z' and rdate between ('" & beginD & "') and ('" & endD & "')"
myCom = New MySqlCommand(strSql1, objConn)
myDrEr = myCom.ExecuteReader
While myDrEr.Read
DataGridView3.Rows.Add()
DataGridView3.Item(0, erRow).Value = myDrEr("hn")
DataGridView3.Item(1, erRow).Value = myDrEr("rdate")
DataGridView3.Item(2, erRow).Value = myDrEr("name")
DataGridView3.Item(3, erRow).Value = myDrEr("icd10")
DataGridView3.Item(4, erRow).Value = myDrEr("icdName1")
erRow += 1
End While
myDrEr.Close()
End While
myDr.Close()