Jessica Jessica - 2 months ago 10
Vb.net Question

Logon fails if two tables are in the dataSet

My report fills two tables. It works on the local server, but when published to another server it gives the following error:


Unable to connect. Login failed.


When I take off the second table and only use the first table, the report works. How can I resolve this?

objDataTable = New Data.DataTable
objDataTable.TableName = "Table"
objDataTable.Columns.Add("pes_nom", GetType(String))

objRow = objDataTable.NewRow
objRow("pes_nom") = objProposta.clsPessoa.pesNom
objDataTable.Rows.Add(objRow)

objDataSet = New Data.DataSet

objDataSet.Tables.Add(objDataTable)

If objProposta.clsDependente.DtDependentes IsNot Nothing Then
Dim dtCloned As New Data.DataTable
dtCloned = objProposta.clsDependente.DtDependentes.Clone()
dtCloned.Columns(3).DataType = System.Type.GetType("System.String")

For Each row As Data.DataRow In objProposta.clsDependente.DtDependentes.Rows
dtCloned.ImportRow(row)
Next

dtCloned.TableName = "Dependentes"
objDataSet.Tables.Add(dtCloned)
End If

Bmgviewer1.PathReport = "RptTermoAdesaoHAP.rpt"
Bmgviewer1.DataSet = objDataSet
Bmgviewer1.DataBind()

Answer

The solution was insert all data in just one table with multiple rows.

I added the following code:

   If objProposta.clsDependente.DtDependentes IsNot Nothing Then
            For Each row As Data.DataRow In objProposta.clsDependente.DtDependentes.Rows

                objRow("dep_nom") = row.Item("dep_nom").ToString()
                objRow("dep_cpf_cgc") = row.Item("dep_cpf_cgc").ToString()

                objDataTable.Rows.Add(objRow)
                objRow = objDataTable.NewRow
            Next
        Else
            objDataTable.Rows.Add(objRow)
        End If

And it worked.