I have this code to perform a search of my database and fill out a textbox the code works but I will tell you in the code that I will read that in a catch block that shows me some messagebuttons YesNo and that it will perform certain actions happens that if it does not read simply what it does is that it does not execute the search, it does not give an error, it does not stop the program or show the messagebuttons it just does not do anything, but if I enter a code that exists, it works correctly.
Private Sub btnbuscar2_Click(sender As Object, e As EventArgs) Handles btnbuscar2.Click
Try
Dim con As New SqlClient.SqlConnection("Data Source=SAMUELSUSANA; Initial catalog=poovb;integrated security=true")
Dim cmd As New SqlClient.SqlCommand("select * from tblsuplidores where Suplidor_ID='" & txtcodigosuplidor.Text & "'", con)
D_table = New DataTable
con.Open()
If (txtcodigosuplidor.Text = "") Then
MessageBox.Show("Debe Pasar El Parametro Del Codigo del Suplidor Para Realizar La Busqueda.", "Hola, Disculpa", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtcodigosuplidor.Focus()
Else
dr = cmd.ExecuteReader
If (dr.Read) Then
txtsuplidor.Text = dr("Nombre").ToString
txtcantidad.Enabled = True
txtcodigosuplidor.Enabled = False
btnbuscar2.Enabled = False
txtcantidad.Focus()
Else
End If
End If
con.Close()
dr.Close()
Catch ex As Exception
Dim Respuesta As DialogResult
Respuesta = MessageBox.Show("Desea Consultar Por un Suplidor?", "Busqueda Erronea.", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)
If (Respuesta = DialogResult.Yes) Then
Consultasuplidores.Show()
Else
txtcodigosuplidor.Clear()
txtcodigosuplidor.Focus()
End If
End Try
End Sub