I have this code to pass the data:
Using Conn As New SqlConnection("Data Source=SAMUELSUSANA; Initial catalog=poovb;integrated security=true")
Conn.Open()
Dim ConsultaSQL = "SELECT TOP 1 Codigo_venta FROM tblventas ORDER BY Codigo_venta DESC"
lblcodigo.Text = New SqlCommand(ConsultaSQL, Conn).ExecuteScalar().ToString()
End Using
If my table has at least one code, a sale works, but if it does not, it throws this error: Object reference not established as an instance of an object.