Vous êtes sur la page 1sur 1

Imports System.Data.

SqlClient
Imports System.Data.Sql
'///***** ESTO ES PARA AUTO COMPLETAR LA CAJA DE TEXTO****//
Public conexiones As SqlConnection
Public enunciado As SqlCommand
Public respuesta As SqlDataReader
Public adaptador As SqlDataAdapter

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.Even


tArgs) Handles MyBase.Load
abrir()
autoCompletarTexbox(txtID)
End Sub

End Sub
' //**************** ESTE CODIGO SIRVE PARA AUTOCOMPLETAR TEXTBOX ********//
Sub abrir()
Try
conexiones = New SqlConnection("Data Source=(local);Initial Catalog=
JAZMIN;Integrated Security=True")
conexiones.Open()
' MsgBox("Conexion exitosa", MsgBoxStyle.Information, "Se ha conecta
do correctamente") '
Catch ex As Exception
MsgBox("Error al realizar la conexion" & ex.Message, MsgBoxStyle.Cri
tical, "Error de conexion")
conexiones.Close() 'Cierra la conexion'
End Try
End Sub
'Llena un texbox con opciones de autocompletar'
Sub autoCompletarTexbox(ByVal campoTexto As TextBox)
Try
enunciado = New SqlCommand("select ID from DATOS", conexiones)
respuesta = enunciado.ExecuteReader()
While respuesta.Read
campoTexto.AutoCompleteCustomSource.Add(respuesta.Item("ID"))
End While
respuesta.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

Vous aimerez peut-être aussi