como asignar un campo de sql a mi textbox...URGE
Publicado por Pedro Canizales Arredondo (8 intervenciones) el 10/03/2011 19:23:02
Hola buenas tardes
estoy teniendo problemas al asignar un campo de mi Base de datos en SQL 2005 a un textbox de mi pantalla, no se como asignarlo tengo el siguiente codigo
Private Sub BtnBuscar_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBuscar.Click
'Dim BuscaControl As String
Limpiacampos()
TipoMov = 3
If TxtControl.Text <> "" Then
BtnControl.Enabled = False
SqlString.CommandType = CommandType.Text
SqlString.Connection = SQLConn
SqlString.CommandText = "Exec SisBascula_Cargacontrol '" & BtnControl.Text & "',1,2"
SQLConn.Open()
LeeDatos = SqlString.ExecuteReader
If LeeDatos.HasRows = True Then
LeeDatos.Read()
TxtNca.Text = LeeDatos.Item("NCA") <---AQUI ME MANDA MENSAJE DE ERROR
' ComBoxCliente.SelectedValue = LeeDatos.Item("Id_Cliente")
' ComBoxTrans.SelectedValue = LeeDatos.Item("Id_Transportista")
End If
SQLConn.Close()
Else
BtnControl.Focus()
End If
End Sub
COMO SOY NUEVO EN ESTO DEL VISUAL BASIC.NET NO HE PODIDO ASIGNAR UN CAMPO EN UN TEXTBOX
ALGUIEN ME PUDIERA ACONSEJAR QUE HACER?
EL ERROR QUE ME MARCA ES el sig:
NO SE CONTROLA INVALIDCASTEXCEPTION
la conversion del tipo 'DBNull' en el tipo 'string' no es valido
estoy teniendo problemas al asignar un campo de mi Base de datos en SQL 2005 a un textbox de mi pantalla, no se como asignarlo tengo el siguiente codigo
Private Sub BtnBuscar_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBuscar.Click
'Dim BuscaControl As String
Limpiacampos()
TipoMov = 3
If TxtControl.Text <> "" Then
BtnControl.Enabled = False
SqlString.CommandType = CommandType.Text
SqlString.Connection = SQLConn
SqlString.CommandText = "Exec SisBascula_Cargacontrol '" & BtnControl.Text & "',1,2"
SQLConn.Open()
LeeDatos = SqlString.ExecuteReader
If LeeDatos.HasRows = True Then
LeeDatos.Read()
TxtNca.Text = LeeDatos.Item("NCA") <---AQUI ME MANDA MENSAJE DE ERROR
' ComBoxCliente.SelectedValue = LeeDatos.Item("Id_Cliente")
' ComBoxTrans.SelectedValue = LeeDatos.Item("Id_Transportista")
End If
SQLConn.Close()
Else
BtnControl.Focus()
End If
End Sub
COMO SOY NUEVO EN ESTO DEL VISUAL BASIC.NET NO HE PODIDO ASIGNAR UN CAMPO EN UN TEXTBOX
ALGUIEN ME PUDIERA ACONSEJAR QUE HACER?
EL ERROR QUE ME MARCA ES el sig:
NO SE CONTROLA INVALIDCASTEXCEPTION
la conversion del tipo 'DBNull' en el tipo 'string' no es valido
Valora esta pregunta


0