How do I catch and send a message to the user if the text entered in the Where clause is not found among the records in the data reader?
VB Code:
Try cnn.ConnectionString = (.........) cnn.Open() cmd = cnn.CreateCommand cmd.CommandText = "SELECT Phase FROM JCPM WHERE VbPhase=" _ & "'" & txtPC.Text & "'" dr = cmd.ExecuteReader While dr.Read() txtPhaseCode.Text = dr("Phase") End While dr.Close() cnn.Close() Catch ex As Exception MsgBox("Error: " & ex.Source & ": " & ex.Message, _ MsgBoxStyle.OKOnly, "Job Name Error") End Try




Reply With Quote