我的代码出了什么问题?
Sub _PID()
Try
cn = New OleDbConnection(conn)
If cn.State = ConnectionState.Closed Then
cn.Open()
Else
cn.Close()
End If
cmd = New OleDbCommand("SELECT MAX(_PID) FROM PatientRegistration", cn)
Dim dr As OleDbDataReader = cmd.ExecuteReader
If dr.Read = True Then
Me.txtPID.Text = dr.Item(0) + 1
Else
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try