Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
System.NullReferenceException: 'Object reference not set to an instance of an object.' dt fue Nothing. en visual basic

VB
Try
            Dim lc As New LClientes

            Dim dt As DataTable = lc.Consultar(TxtNumId.Text)

            Dim dr As DataRow = dt.Rows.Item(0)

            TxtIdCliente.Text = dr.Item("ID_CLIENTE")
            TxtNombre.Text = dr.Item("NOMBRE")
            TxtTelefono.Text = dr.Item("TELEFONO")
        Catch ex As Exception
            MsgBox("El cliente no existe")
        End Try


What I have tried:

revise el codigo con el desarrollador del software original
Posted
Updated 18-Jul-23 5:38am
v2
Comments
Andre Oosthuizen 18-Jul-23 11:10am    
This is an english site, I have no idea what 'revise el codigo con el desarrollador del software original' means.

this Execption means that you have declared a DataTable but there is nothing in it what could be referenced.
To solve this problem it's up to you because we don't have your Software and also not your Data - but : inside your development-system you have the Debugger which could show you what exactly happens ...
 
Share this answer
 
VB
Dim dt As DataTable = lc.Consultar(TxtNumId.Text)

If dt is null then it means that the call to lc.Consultar is not returning anything. You will need to use the debugger to find out why.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900