Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
while verifydatabase from vb.net web application for the cristal report gives Log on failed.error. here is my code. I am using project data (class defined in my visual studio project) as Database Fields do it should not need any logon I belive.


Dim tmpWsAssetsManagement As New WsAssetsManagement
Dim tmpClsAssetCollection As New List(Of ClsAssetsItemsIndexCard_Record)()

Try
    ' Retrieve asset list from the SQL table using a web service to fill a DataTable
    Dim tmpClsAssetRecord As New ClsAssetsItemsIndexCard_Record
    tmpClsAssetRecord.ClsCustomerId = 1000 'ID
    Dim tmpDtAssetsManagement As DataTable = tmpWsAssetsManagement.AssetsCristalReport_SELECT("00", tmpClsAssetRecord, MyRcError)
    If Not String.IsNullOrEmpty(MyRcError) OrElse tmpDtAssetsManagement Is Nothing Then
        ' Handle error cases
        Throw New Exception("Error Generating Asset Report: " & MyRcError)
    ElseIf tmpDtAssetsManagement.Rows.Count <= 0 Then
        ' Handle case when no data is found
        Throw New Exception("No Data Found To Populate Asset Report.")
    End If

    ' Populate the class collection from the datatable retrieved
    tmpClsAssetCollection = PopulateItemDetailsFromDataTable(tmpDtAssetsManagement)

    '----- Load your Crystal Report file
    '-------------------------------------------------------------------------------------
    Dim rptPath As String = Server.MapPath("~/xxxxx/yyyyy.rpt")

    Dim rpt As New ReportDocument()
    rpt.Load(rptPath)

    ' logon the database
    CristalReportLogon(rpt)
    rpt.VerifyDatabase()
    ' Set the class collection as the report's data source
    rpt.SetDataSource(tmpClsAssetCollection)

    ' Set CrystalReportViewer to display the report
    rptVieverAssetsIndexCard.ReportSource = rpt
    rptVieverAssetsIndexCard.Visible = True

Catch ex As Exception
    ' Handle exceptions
    Dim tmpErrorCode As String = "(20000200001-2206-000) "
    Dim tmpErrorMessage As String = "- Critical Error Generating Asset Report."
    LblErrorMessage.Text = tmpErrorCode & tmpErrorMessage
    LblErrorMessage.Attributes.Add("style", "color:red")

    GlbLogKeepingOperations(tmpErrorCode, {LblErrorMessage.Text, ex.Message, Session("SesUserID").ToString})

Finally
    ' Clean up resources
    If Not IsNothing(tmpWsAssetsManagement) Then tmpWsAssetsManagement.Dispose()
    If Not IsNothing(tmpClsAssetCollection) Then tmpClsAssetCollection = Nothing
End Try


What I have tried:

with
rpt.VerifyDatabase()
line I get Login Failed error. If i remove that line report opens in the web application asking for logon credentials which i dont know what to put as it comes as class from the project.

Thanks in advance for all the help you provide.
Posted

1 solution

The error is quite obvious, as you stated yourself, the report writer is trying to connect to your database, you gave it no login details and it will thus ask you for the detail. You need to specify the login details before you call the report so it is connected to your database succesfully.

Use your debugger to see where in the calss it requires the login detail?
 
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