Ver Mensaje Individual
  #2 (permalink)  
Antiguo 10/07/2009, 10:45
Avatar de jaullo
jaullo
 
Fecha de Ingreso: abril-2009
Mensajes: 994
Antigüedad: 15 años
Puntos: 30
Respuesta: registros a un textbox para modificarlos

Prueba con algo como esto

Dim objconexion As New SqlClient.SqlConnection
Dim strconexion As String = "Data Source=tuserver;Initial Catalog=tubd;User ID=tuuser;Password=tupass"

Sub abrirbasedatos()
If objconexion.State = ConnectionState.Closed Then
objconexion.ConnectionString = strconexion
objconexion.Open()
End If
End Sub

'____seccion de consultas

Function buscar(ByVal cSQL$) As SqlClient.SqlDataReader
Try
abrirbasedatos()
Dim objcommand As New SqlClient.SqlCommand(cSQL, objconexion)
Return objcommand.ExecuteReader()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function

'trae los datos de la BD
Function buscar()
Try
Dim datareader As SqlClient.SqlDataReader
datareader = objaux.buscar("select * from tubd where factura='" & txt1.Text & "' ")
If datareader.HasRows Then

While datareader.Read
txt1.Text = "" & datareader.Item("campo1")
txt2.Text = "" & datareader.Item("campo2")


End While
datareader.close()
Else
MsgBox("No se han Encontrado registros", MsgBoxStyle.Information)
End If

datareader.Close()

Catch ex As Exception
MsgBox("Error al Buscar los datos: " & ex.Message)
End Try

Espero te sirva