Results 1 to 39 of 39

Thread: [RESOLVED] Setting DB location during codeing in CR 11

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Resolved [RESOLVED] Setting DB location during codeing in CR 11

    Hi

    While making a report in CR11 we specify the DB

    But What if I wanna specify the DB during codeing..

    How do i do that.. the DB is in location

    Code:
    app.path & "\DB\data.mdb"
    thanks

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    please help..

    because what is happening.. when i create an installer and run the prog.. then the viewer asks for path again because the specified path during design time is not the same as the installed path.. so this can be a lot of problem...

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

    Re: Setting DB location during codeing in CR 11

    if you are working in VB then read crystal report tutorial at my signature.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    hi

    could not find an example where i can specify the database in codeing

    please paste an example here.. thanks

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

    Re: Setting DB location during codeing in CR 11


  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    I did check that..

    could not find any code which was showing a path to DB.. all are connecting to rpt..

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

    Re: Setting DB location during codeing in CR 11

    Out you DB and the report at the
    vb Code:
    1. App.Path

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    so like

    vb Code:
    1. With CrystalReport1
    2.     .ReportFileName = App.Path & "\ReportName.rpt" & "\db\db.mdb"

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

    Re: Setting DB location during codeing in CR 11

    Quote Originally Posted by khandu
    so like

    vb Code:
    1. With CrystalReport1
    2.     .ReportFileName = App.Path & "\ReportName.rpt" & "\db\db.mdb"
    No post your whole code

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    not working on code
    Last edited by khandu; Mar 21st, 2007 at 02:54 PM.

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

    Re: Setting DB location during codeing in CR 11

    are you using VB.NET

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    VB 6.0

    i got the above code help from another person..

    please help with the DB path

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

    Re: Setting DB location during codeing in CR 11

    But What if I wanna specify the DB during codeing..
    No need
    use the DB Path in the connection USE the DSN for the report.
    I make report In the VB 6.0 using the DSN not the DB Path

    I suggest you that if you are using the connection string in the project then use the DSN
    ans make report using the DSN
    Then they call automaticallly

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    Hi i m totally new to this

    can u explain exactly what to do in the report..

    this is how i do in the design


  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    Hi

    Some help here Shakti please.. show me what codes to add on top to define "app.path & "/db/db.mdb"

    thanks

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

    Re: Setting DB location during codeing in CR 11

    Tell me what are you using in your project DSN or connectionstring

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    as i showed u the code on top..

    I designed a rpt in CR11 directly and gave a direct connection to it and picked up fields from there.. so its always asking for that path which i gave from browse.. i think its DSN..

    the pic above shows i gave a direct connection

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    bump.. help plz

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    shakti

    please help out

    how to mention to pick db from app.path & "\asd\db.mdb"

    please help here..

  20. #20
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Setting DB location during codeing in CR 11

    I have never used CR 11 but the CRAXDRT of prior versions all have a method that lets you specify the database location of every table. Something like

    Code:
    For Each DatabaseTable in DatabaseTables
       DatabaseTable.SetLocation App.Path & "\Data\Database.mdb"
    Next
    I don't access to Crystal right now so cannot confirm the actual method names. Anyways, use the help file or object browser to find the object/method you need to call.

  21. #21

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    the method

    .setlocation is not showing in the CR 11

  22. #22
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Setting DB location during codeing in CR 11

    .SetLocation was just my guess for the method name.

    What other methods are there in CR 11? You are allowed to think for yourself...

  23. #23

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    cannot find any such method for it..

  24. #24
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Setting DB location during codeing in CR 11

    According to the online documentation, use the SetTableLocation method, Location property or the ConnectionProperties property of the DatabaseTable object.

  25. #25

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    I tried this.. i use DAO for connection to DB in the project

    vb Code:
    1. For Each crxDatabaseTable In crxDatabaseTables
    2. crxDatabaseTable.SetDataSource App.Path & "\database\db.mdb"
    3. Next

    Gave the error

    Code:
    Run time error 424 Object required
    This is the syntax showing for setdatasource

    SetDataSource Method (Database Object)
    The SetDataSource method is used to provide information about a data source to the database driver associated with this Database object at runtime. For instance, if a report has been designed using the Crystal Active Data Driver this method can be used to provide an active data source for the report, such as a DAO, ADO, or RDO Recordset or a CDO Rowset. In this case, the object passed to the second parameter of this method replaces, at runtime, the field definition file used to create the report. This method can be invoked only in formatting Idle mode. When using a secure connection such as SQL Server, some additional code is required

    Syntax
    Sub SetDataSource (data, [dataTag], [tableNumber])


  26. #26
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Setting DB location during codeing in CR 11

    The SetDataSource method expects an object, like a DAO.Recordset or ADO.Recordset, not the path to a database file. Are you trying to pass a DAO.Recordset to the report?

    Code:
    For Each crxDatabaseTable In crxDatabaseTables
    crxDatabaseTable.Location App.Path & "\database\db.mdb"
    Next
    http://devlibrary.businessobjects.co.../en/devlib.htm
    Last edited by brucevde; Mar 11th, 2007 at 12:10 PM.

  27. #27

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    well, it says invalid use of property for above also..

    man..

  28. #28
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Setting DB location during codeing in CR 11

    crxDatabaseTable.Location = App.Path & "\database\db.mdb"

    Did you even try looking at the documentation? A little browsing and you would've found

    http://devlibrary.businessobjects.co...0.html#1686406

  29. #29

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    I tried as suggested.. still the same error

    Object variable or With block variable not set (Error 91)
    on the above mentioned line..

  30. #30

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    *bump*

    can some1 please upload a small proj here showing how to select manual location of DB for CR11 reports in VB6 during runtime..
    thanks

  31. #31

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    *bump*

  32. #32

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    *bump* please help someone..

  33. #33
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Setting DB location during codeing in CR 11

    I don't understand why the link posted earlier does not help you. I don't have CR11 so cannot create a sample app. Post your modified code...

    http://devlibrary.businessobjects.co...0.html#1686406

  34. #34
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Setting DB location during codeing in CR 11

    This is what I use to do CRXI with VB6

    On a form that hold the ReportVeiwer do the following:

    In the Declations section of the form:
    vb Code:
    1. Private m_App As New CRAXDDRT.Application
    2. Private m_Rep As New CRAXDDRT.Report
    3. Public mRepName As String
    4. Public mstrW As String
    5. Public mstrUName As String
    6. Public msRepTitle As String
    7. Public mstrRef As String
    8. Public mstrC3 As String
    9.  
    10. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Now create a sub Named DisplayReport:
    vb Code:
    1. Public Sub DisplayReport()
    2. Dim ConnectionInfo As CRAXDDRT.ConnectionProperties
    3. Dim strPNameP As String
    4. Dim test As String
    5.  
    6.  
    7. Set m_Rep = Nothing
    8. strPNameP = mRepName
    9. mRepName = App.Path & "\" & mRepName
    10. test = gstrDBLoc & "\" & gstrDBName
    11.  
    12. Set m_Rep = m_App.OpenReport(mRepName, 1)
    13. If strPNameP = "RempRep1.rpt" Then
    14.     m_Rep.RecordSelectionFormula = m_Rep.RecordSelectionFormula & mstrW
    15. ElseIf strPNameP = "RempRep1_HB.rpt" Then
    16.     m_Rep.RecordSelectionFormula = m_Rep.RecordSelectionFormula & mstrW
    17. ElseIf strPNameP = "RempRep2.rpt" Then
    18.     m_Rep.RecordSelectionFormula = m_Rep.RecordSelectionFormula & mstrW
    19. ElseIf strPNameP = "RempRep2_HB.rpt" Then
    20.     m_Rep.RecordSelectionFormula = m_Rep.RecordSelectionFormula & mstrW
    21. Else
    22.     m_Rep.RecordSelectionFormula = mstrW
    23. End If
    24. Set ConnectionInfo = m_Rep.Database.Tables(1).ConnectionProperties
    25. On Error Resume Next
    26. m_Rep.Database.Tables(1).DllName = "crdb_dao.dll"
    27. ConnectionInfo.DeleteAll
    28. ConnectionInfo.Add "Database Name", test
    29. ConnectionInfo.Add "Session UserID", "Report"
    30. ConnectionInfo.Add "Session Password", ""
    31. ConnectionInfo.Add "System Database Path", gstrDBLoc & "\Security.mdw"
    32.  
    33.  
    34. If strPNameP = "FSSResultsbyNuclide(Area)_New.rpt" Then
    35.     m_Rep.ReportTitle = "Sample Results by Rank"
    36. ElseIf strPNameP = "FSSSamplesforAreaDetail_New.rpt" Then
    37.     m_Rep.ReportTitle = "Sample Analysis Results by Area"
    38. ElseIf strPNameP = "DataFrequencyPlot.rpt" Then
    39.     m_Rep.ReportTitle = "Data Frequency Plot for " & fRepGen.cboIsotopes.Text
    40. ElseIf strPNameP = "E600SurveysinArea.rpt" Then
    41.     m_Rep.ReportTitle = msRepTitle
    42. ElseIf strPNameP = "DataQuantPlot.rpt" Then
    43.     m_Rep.ReportTitle = "Data Quantile Plot for " & fRepGen.cboIsotopes.Text
    44. ElseIf strPNameP = "AreaComps.rpt" Then
    45.     m_Rep.EnableParameterPrompting = False
    46.     m_Rep.ParameterFields(1).AddCurrentValue (mstrRef)
    47.     m_Rep.ParameterFields(2).AddCurrentValue (Me.mstrC3)
    48. ElseIf strPNameP = "RempRep1.rpt" Then
    49.     m_Rep.EnableParameterPrompting = False
    50.     m_Rep.ParameterFields(1).AddCurrentValue mstrC3
    51. ElseIf strPNameP = "RempRep1_HB.rpt" Then
    52.     m_Rep.EnableParameterPrompting = False
    53.     m_Rep.ParameterFields(1).AddCurrentValue mstrC3
    54. ElseIf strPNameP = "RempRep2.rpt" Then
    55.     m_Rep.EnableParameterPrompting = False
    56.     m_Rep.ParameterFields(1).AddCurrentValue mstrC3
    57. ElseIf strPNameP = "RempRep2_HB.rpt" Then
    58.     m_Rep.EnableParameterPrompting = False
    59.     m_Rep.ParameterFields(1).AddCurrentValue mstrC3
    60. End If
    61.  
    62. crView.ReportSource = m_Rep
    63.  
    64. Sleep 2000
    65.  
    66. crView.ViewReport
    67. 'crView.Zoom 1
    68.  
    69. If strPNameP = "AreaComps.rpt" Then
    70.     m_Rep.ParameterFields.Delete (1)
    71.     m_Rep.ParameterFields.Delete (2)
    72. ElseIf strPNameP = "RempRep1.rpt" Then
    73.     m_Rep.ParameterFields.Delete (1)
    74. ElseIf strPNameP = "RempRep1_HB.rpt" Then
    75.     m_Rep.ParameterFields.Delete (1)
    76. ElseIf strPNameP = "RempRep2.rpt" Then
    77.     m_Rep.ParameterFields.Delete (1)
    78. ElseIf strPNameP = "RempRep2_HB.rpt" Then
    79.     m_Rep.ParameterFields.Delete (1)
    80. End If
    81. Set m_Rep = Nothing
    82.  
    83. End Sub

    That is called from the print but on the form I have to generate the reports. This use a security database and uses group security. But you should get the basic idea of how to do this here.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  35. #35

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    error is mentioned on top
    Last edited by khandu; Mar 21st, 2007 at 02:57 PM.

  36. #36
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Setting DB location during codeing in CR 11

    What Error? At the top of what?

    Did you include the references for Crystal as follows:
    Crystal Reports Viewer Library 11.0
    Crystal Reports ActiveX Designer Design and Runtime Library 11.0
    Crystal Reports Activex Designer Runtime Library 11.0
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  37. #37

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    yes.. all the runtime are included


    I get the error on the line

    For Each crxDatabaseTable In crxDatabaseTables

    Runtime 424 Object required

    some1 please modify the above code so that i can mention the DB location at runtime for the reports..
    Last edited by khandu; Mar 21st, 2007 at 02:55 PM.

  38. #38
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Setting DB location during codeing in CR 11

    Use the following code but place it after the report is opened, ie after
    Set crxReport = crxApp.OpenReport(reportname)

    Code:
    Set crxDatabaseTables = crxReport.Database.Tables
    
    For Each crxDatabaseTable In crxDatabaseTables
       crxDatabaseTable.Location = App.Path & "\database\db.mdb"
    Next

  39. #39

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    139

    Re: Setting DB location during codeing in CR 11

    excellent.. repped and FINALLY RESOLVED!!!!

    will put that code after all the report call..

    THANKS A LOT!!

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