Crystal Report 10

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raaman rai
    New Member
    • Oct 2007
    • 114

    Crystal Report 10

    Guys, i have created reports in crystal report 10 for my VB application. Now how sud i open the report from my application. Infact i have tried opening the report but i get the following error:
    [HTML]Logon failed.
    Details: ADO Error Code: 0x80040e4d
    Source: Microsoft OLE DB Provider for SQL Server
    Description: Login failed for user 'sa'
    SQL State: 42000
    Native Error: 18456[/HTML]

    My code was:
    [HTML]Dim Appl As New CRAXDRT.Applica tion
    Dim Report As New CRAXDRT.Report
    CrystalActiveXR eportViewer1.To p = 0
    CrystalActiveXR eportViewer1.Le ft = 0
    CrystalActiveXR eportViewer1.He ight = ScaleHeight
    CrystalActiveXR eportViewer1.Wi dth = ScaleWidth
    Set Report = Appl.OpenReport ("e:\report\rpt master.rpt")
    CrystalActiveXR eportViewer1.Re portSource = Report
    CrystalActiveXR eportViewer1.Vi ewReport[/HTML]

    My database is located in a network server wher SQL server is installed n i have created an odbc datasource for the connection. I have used the same connection with the report an it works. I have added the username and password to access the database in the report. It connects well and can retrieve the data. But when i open the same report via Visual Basic i get the above errors.

    What is the possible cause????? Plus i need 2 ask why i cannot find the Crystal Report Viewer Control 10 in the componenents list as suggested by some ppl. I get the Crystal ActiveX report viewer control instead.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Try this sample code

    The following code uses crystal report viewer and connection is for oracle database.

    [code=vb]
    Public Sub ReportDisplay(Q uery As String)

    Set CRXReport = CrystalReport1
    Set CRXDb = CRXReport.Datab ase
    CRXReport.Disca rdSavedData

    inti = 1
    Do Until inti = CRXReport.Datab ase.Tables.coun t + 1
    CRXReport.Datab ase.Tables.Item (inti).SetLogOn Info strdblocation, "orcl", "debasis", "debasis"
    inti = inti + 1
    Loop

    CrystalReport1. SQLQueryString = Query

    With FrmReport
    .Show
    .CRV1.ReportSou rce = CRXReport
    .CRV1.ViewRepor t
    End With

    Set CRXReport = Nothing
    End Sub

    [/code]

    Comment

    • raaman rai
      New Member
      • Oct 2007
      • 114

      #3
      i did try ur code but i couldnt succed and i tried the following code but still not working;
      [HTML]
      Dim Appl As New CRAXDRT.Applica tion
      Dim Report As New CRAXDRT.Report
      CrystalActiveXR eportViewer1.To p = 0
      CrystalActiveXR eportViewer1.Le ft = 0
      CrystalActiveXR eportViewer1.He ight = ScaleHeight
      CrystalActiveXR eportViewer1.Wi dth = ScaleWidth
      Set Report = Appl.OpenReport ("e:\reports\rp tmaster.rpt")
      Report.Database .LogOnServer "p2ssql.dll ", "192.168.0. 1", "cab", "sa", "123456"
      CrystalActiveXR eportViewer1.Re portSource = Report
      CrystalActiveXR eportViewer1.Vi ewReport[/HTML]

      Can i know any other alternatives?

      Comment

      • raaman rai
        New Member
        • Oct 2007
        • 114

        #4
        Ultimately, i found this solution n it worked 4 me. N i m sure it will work for every body too. So, i m leaving this code for the reference to the ppl with the same problem

        [HTML]
        Dim Appl As New CRAXDRT.Applica tion
        Dim Report As New CRAXDRT.Report
        CrystalActiveXR eportViewer1.To p = 0
        CrystalActiveXR eportViewer1.Le ft = 0
        CrystalActiveXR eportViewer1.He ight = ScaleHeight
        CrystalActiveXR eportViewer1.Wi dth = ScaleWidth
        Set Report = Appl.OpenReport ("your report path")
        Report.Database .LogOnServer "p2ssql.dll ", "your servername", "your database", "your username", "your password"
        For i = 1 To Report.Database .Tables.Count
        Report.Database .Tables(i).Conn ectionPropertie s.Item("Passwor d") = "your password"
        Next i
        CrystalActiveXR eportViewer1.En ableGroupTree = False
        CrystalActiveXR eportViewer1.Re portSource = Report
        CrystalActiveXR eportViewer1.Vi ewReport
        [/HTML]
        But please note that i havent tried this with the Windows Authentication for SQL Server.And i would like to say that the report opens very late...which i cannot say...plus i would recommend to use Crystal32.ocx component rather than the Crviewer. I think it will be better in terms of opening the report faster and the implementation approach (i mean the coding) is easier if you already have the report created.All the best!

        Comment

        Working...