Results 1 to 16 of 16

Thread: Crystal Reports XI with Visual Basic 6.0

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Posts
    22

    Crystal Reports XI with Visual Basic 6.0

    Crystal Reports XI With Visual Basic 6.0
    ' Add Form And rename to FrmRepView
    ' Add Code to Module

    VB Code:
    1. Sub ReporView(SQLsentence As String, ViewName As String, ReportName As String)
    2.             On Error Resume Next
    3.             Dim CN As New ADODB.Connection
    4.             Dim rss As New Recordset
    5.             Dim appw As New CRAXDDRT.Application
    6.             Dim rpt As New CRAXDDRT.Report
    7.             Dim tbl As CRAXDDRT.DatabaseTable
    8.             Dim db As New ADODB.Connection
    9.             CN.Execute "Drop View " & ViewName
    10.             CN.Execute "Create View " & ViewName & " as " & SQLsentence
    11.             x = App.Path & "\" & ReportName & ".rpt"
    12.             appw.LogOnServer "crdb_odbc.dll", "GRS", "GRS", "sa", "asd123"
    13.             Set rpt = appw.OpenReport(x)
    14.             rpt.Database.LogOnServer  "crdb_odbc.dll", "GRS", "GRS", "sa", "asd123"
    15.             FrmRepView.show
    16.             FrmRepView.CrystalActiveXReportViewer1.Refresh
    17.             FrmRepView.CrystalActiveXReportViewer1.ReportSource = rpt
    18.             FrmRepView.CrystalActiveXReportViewer1.ViewReport
    19.             ' appw.LogOnServer "crdb_odbc.dll", "GRS", "GRS", "sa", "asd123"
    20.             'DSN=grs;USER ID=sa;pwd=asdsuez;
    21.         End Sub
    thes Code Work With Me

    But
    I Use Sql Server 2000
    The problem Is When I Change Database Name
    And Cang DSN To New Database

    The Report Not View result
    And Gev Me Error Logon failure

    If Eny own Now The problem Help me please !

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Crystal Reports XI with Visual Basic 6.0

    rpt.Database.LogOnServer "crdb_odbc.dll", "GRS", "GRS", "sa", "asd123"
    You are using odbc rather than oledb provider. I don't CR11 to test but I think there is another option how to login so check your documentation and see if you can switch to oledb instead - this way you won't have to create odbc entry.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Crystal Reports XI with Visual Basic 6.0

    Moved to reporting section

  4. #4
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: Crystal Reports XI with Visual Basic 6.0

    The Report Not View result
    And Gev Me Error Logon failure
    Open the Crystal report and click on the varify database.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Posts
    22

    Re: Crystal Reports XI with Visual Basic 6.0

    Yes I now But I need A solution By Code
    to Can Run More Then Program In The same Server
    With Other Database Name

  6. #6
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Arrow Re: Crystal Reports XI with Visual Basic 6.0

    Verify database is necessary for the crystal report. It is the CR property and used for check the database and the table with the proper field that we are using in the CR.
    By coding verify the database in the CR is same as the making the CR by coding.
    By coding we are able to check the database at the proper location but I never verify the database of the CR by coding.
    Search at the CR site.
    I am searching about it.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Posts
    22

    Re: Crystal Reports XI with Visual Basic 6.0

    Thes Is My Code After verify the database in the Crystal Reports XI

    I tested And it Work With me


    VB Code:
    1. Dim rss As New Recordset
    2.     Dim appw As New CRAXDDRT.Application
    3.     Dim rpt As New CRAXDDRT.Report
    4.     Dim tbl As CRAXDDRT.DatabaseTable
    5.     Dim Tdsn, Tid, Tpwd, tdb, tser As String
    6.  
    7.     '
    8.     Tdsn = "asd"
    9.     Tid = "sa"
    10.     Tpwd = "123"
    11.     tdb = "AGC"
    12.     tser = "Server"
    13.  
    14.     cn.Execute "Drop View " & ViewName
    15.     cn.Execute "Create View " & ViewName & " as " & SQLsentence
    16.     X = App.Path & "\rep\" & ReportName & ".rpt"
    17.     appw.LogOnServer "crdb_odbc.dll", Tdsn, tdb, Tid, Tpwd
    18.     Set rpt = appw.OpenReport(X)
    19.     rpt.Database.LogOnServer "crdb_odbc.dll", Tdsn, tdb, Tid, Tpwd
    20.     cfg = rpt.Database.Tables.Count
    21.  
    22.  
    23.     sserver = "ASD" 'dsn name
    24.     sDatabase = "AGC"
    25.     sDBUserName = "sa"
    26.     sDBPassword = "123"
    27.  
    28.     For Each tbl In rpt.Database.Tables
    29.         Msdd = tbl.Name
    30.         tbl.SetLogOnInfo sserver, sDatabase, sDBUserName, sDBPassword
    31.         sTblName = tbl.Name
    32.         tbl.Location = sDatabase & ".dbo." & sTblName
    33.         If Not tbl.TestConnectivity Then
    34.             '<can't connect error processing>
    35.             Exit For
    36.         End If
    37.     Next
    38.  
    39.  
    40.     Form1.CrystalActiveXReportViewer1.Refresh
    41.     Form1.CrystalActiveXReportViewer1.ReportSource = rpt
    42.     Form1.CrystalActiveXReportViewer1.ViewReport
    Do Not Ever Stop Study

  8. #8
    New Member
    Join Date
    Apr 2007
    Posts
    1

    Re: Crystal Reports XI with Visual Basic 6.0

    what kind of library add for references the code of CRXI for viewing crystal reports version 6

  9. #9
    New Member
    Join Date
    Jan 2008
    Posts
    2

    Re: Crystal Reports XI with Visual Basic 6.0

    would you please give me the sample code (just for connection and calling the report)

  10. #10
    New Member
    Join Date
    Jan 2008
    Posts
    3

    Re: Crystal Reports XI with Visual Basic 6.0

    If you wish to create an application that allows the user to view an existing crystal report then this is what you do:
    Make sure you have crystal report designer installed first. This will install all the required component for our application.
    Then proceede to Visual Studio and open VB 6.

    1. First create a vb project ( standard exe or ocx)
    2. You will be displayed with a blank form.
    3. Go to Project > Components
    4. Select "Crystal Activex Report Viewer Library 11.0" and Click ok. A new icon should appear in the toolbar.
    5. Then go to Project > References
    6. and select "Crystal Report Activex Designer Runtime Library 11.0"
    7. On the Blank Form drag a crystal report viewer from the toolbar. Name it "crsv1"
    8. Then type the following code:
    Code:
    '***************************************************************************************
    '*  This project uses the following reference for the CRAXDRT object
    '*  Crystal Report Activex Designer Runtime Library 11.0
    '***************************************************************************************
    Private Sub Form_Load()
       
    
     Dim Report As New CRAXDRT.Application
    
     setViewerSize
      
     
     crsv1.ReportSource = Report.OpenReport("C:\crystal_reports\repor1.rpt")
    
     crsv1.ViewReport
     
    
    End Sub
    
    Private Sub form_resize()
     setViewerSize
    End Sub
    
    Private Sub setViewerSize()
     crsv1.Width = Form1.Width - 100
     crsv1.Height = Form1.Height - 400
    End Sub
    Well thats it. if you have any question send me an email
    thanks
    Shah Chandon
    Last edited by skchandon; Jan 16th, 2008 at 10:22 AM.

  11. #11
    New Member
    Join Date
    Jan 2008
    Posts
    3

    Re: Crystal Reports XI with Visual Basic 6.0

    Chandon,
    I tried the steps you have posted. When I ran the code it gave me the following error

    Dim Report As New CRAXDRT.Application "Compile error - user defined type not defined"

    How do I fix that?

    We have 25 reports in Crystal 11. Database is Oracle 10g. We are using VB 6.0 as the front end to run the crystal reports and logonto the Oracle database.

    Thanks,
    Saloni

  12. #12
    New Member
    Join Date
    Jan 2008
    Posts
    3

    Re: Crystal Reports XI with Visual Basic 6.0

    You need the CRAXDRT object.
    one way to get it is to install crystal report designer 11

  13. #13
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Exclamation Re: Crystal Reports XI with Visual Basic 6.0

    Quote Originally Posted by skchandon
    You need the CRAXDRT object.
    one way to get it is to install crystal report designer 11
    AFAIK one needs to install the CR with Developer Key and not Designer Key

  14. #14
    New Member
    Join Date
    Jan 2008
    Posts
    3

    Re: Crystal Reports XI with Visual Basic 6.0

    Quote Originally Posted by VBFnewcomer
    AFAIK one needs to install the CR with Developer Key and not Designer Key
    Really??!!
    I didnt even kno..
    Good thing u mentioned that then.

  15. #15
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Crystal Reports XI with Visual Basic 6.0

    first complete uninstall the existing CR and reinstall with the developer key

  16. #16
    New Member
    Join Date
    Apr 2012
    Posts
    2

    Re: Crystal Reports XI with Visual Basic 6.0

    Quote Originally Posted by skchandon View Post
    If you wish to create an application that allows the user to view an existing crystal report then this is what you do:
    Make sure you have crystal report designer installed first. This will install all the required component for our application.
    Then proceede to Visual Studio and open VB 6.

    1. First create a vb project ( standard exe or ocx)
    2. You will be displayed with a blank form.
    3. Go to Project > Components
    4. Select "Crystal Activex Report Viewer Library 11.0" and Click ok. A new icon should appear in the toolbar.
    5. Then go to Project > References
    6. and select "Crystal Report Activex Designer Runtime Library 11.0"
    7. On the Blank Form drag a crystal report viewer from the toolbar. Name it "crsv1"
    8. Then type the following code:
    Code:
    '***************************************************************************************
    '*  This project uses the following reference for the CRAXDRT object
    '*  Crystal Report Activex Designer Runtime Library 11.0
    '***************************************************************************************
    Private Sub Form_Load()
       
    
     Dim Report As New CRAXDRT.Application
    
     setViewerSize
      
     
     crsv1.ReportSource = Report.OpenReport("C:\crystal_reports\repor1.rpt")
    
     crsv1.ViewReport
     
    
    End Sub
    
    Private Sub form_resize()
     setViewerSize
    End Sub
    
    Private Sub setViewerSize()
     crsv1.Width = Form1.Width - 100
     crsv1.Height = Form1.Height - 400
    End Sub
    Well thats it. if you have any question send me an email
    thanks
    Shah Chandon
    Hi Chandon,
    I used the above code you posted and i am getting Logon Failed error.
    Do i need to include any more information regarding login details.

    Thanks in advance
    Rahul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width