Private Sub selectTrainNO()
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConnection
.Open()
End With
Dim dr As OleDbDataReader
Dim cmd As New OleDbCommand
Dim daChk As OleDbDataAdapter
Dim dsChk As New DataSet
Dim addChk As Boolean = True
Dim sqlselect As String = ""
sqlselect = "SELECT TrainingResult.TrainingNo FROM TrainingResult inner join Training ON TrainingResult.TrainingNo = Training.TrainingNo where =Training.CourseID = '" & txtCouse.Text & "' AND TrainingResult.PersonId =" & txtPer.Text & "' "
cmd = New OleDbCommand()
dsChk.Clear()
daChk = New OleDbDataAdapter(sqlselect, Conn)
daChk.Fill(dsChk, "TrainingResult")
With cmd
.CommandType = CommandType.Text
.CommandText = sqlselect
.Connection = Conn
dr = .ExecuteReader()
End With
dr.Read()
If dr.HasRows Then
TextBox1.Text = CStr(dr(0))
End If
dr.Close()
End Sub