1
When I try to open the company using the Abreempresa method, I get the following error
'Object reference is not defined as an instance of an object.'
Does anyone know how to solve ? Thank you.
The code I use is this:
Public bsERP As New ErpBS
Public plat As New StdPlatBS
Public p_empresa As String = "DEMO"
Public p_username As String = "naurio"
Public p_password As String = "*****"
Public p_instancia As String = "Default"
Public p_versao As String = "10.00"
Public p_plat As String = "EMPRE"
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim tp As EnumTipoPlataforma = EnumTipoPlataforma.tpProfissional
If p_plat = "EMPRE" Then
tp = EnumTipoPlataforma.tpEmpresarial
ElseIf p_plat = "ERPPLAT" Then
tp = EnumTipoPlataforma.tpFirst
End If
Dim objStdTransac As StdBETransaccao = New StdBETransaccao()
'ABRE a plataforma para integrar os anexos
Dim confapl As New StdBSConfApl
Dim trans As New StdBETransaccao
With confapl
.AbvtApl = "ERP"
.Instancia = p_instancia
.Utilizador = p_username
.PwdUtilizador = p_password
.LicVersaoMinima = p_versao
End With
plat.AbrePlataformaEmpresa(p_empresa, trans, confapl, tp)
bsERP.AbreEmpresaTrabalho(tp, p_empresa, p_username, p_password, objStdTransac, p_instancia)
'*************************************************************
If Convert.ToBoolean(bsERP.Base.Clientes.NumeroContribuintesRepetidos("000000000")) Then
MessageBox.Show("Cannot continue because the NIF for the current entity already exist.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Else
Dim customer As BasBECliente = New BasBECliente()
customer.Nome = "naurio"
customer.Cliente = "nau"
customer.NumContribuinte = "000000000"
customer.Moeda = "EUR"
'customer.EmModoEdicao = If(PriEngine.Engine.Base.Clientes.Existe(txtName.Text), True, False)
Try
bsERP.Base.Clientes.Actualiza(customer)
Catch ex As Exception
MessageBox.Show("Unable to save client. " & vbLf & ex.Message)
End Try
End If
'***********************************************************************
bsERP.FechaEmpresaTrabalho()
bsERP.FechaLigacaoBaseDados()
If you can help me solve or an example of using the engines in visual studio on Asp.net. Thank you.
Thank you so much for the help, I understood what was explained and made sense to me to complement the work. But I have another question. I went to Github I used your Exmplos that are developed in C# and work perfectly, but to work in VB.NET the procedure is the same ? I tried to use the same procedure of C# converting the code but I get the same error as this above mentioned.
– Náurio Lutango
In VB.net you may have to adapt the solve, except it should work without problem.
– Sérgio Sereno