CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2006
    Posts
    392

    Thumbs up Set Database Location Problem

    Hi Team,
    I am using crystal report 9. And I have a huge set of reports and sub reports. I have developed my application and now i am going to move it to live. Now I face the problem of setting location for the reports. If set the location by using the root element it is not setting the location for all the reports. It just set the first report and leaves others . Now i have to open each and every record and set the location. Is there any other method to set the location at whole ?
    VS 2005

  2. #2
    Join Date
    Aug 2007
    Posts
    179

    Re: Set Database Location Problem

    please tell me you are using ODBC data sources. If true you only point the dsn to a new data source.

  3. #3
    Join Date
    Sep 2006
    Posts
    392

    Re: Set Database Location Problem

    I am OLEDB Data Source. That is SQL
    VS 2005

  4. #4
    Join Date
    Jul 2005
    Posts
    1,083

    Re: Set Database Location Problem

    Crystal Reports' report designed using OLEDB (ADO) as data source

    This example demonstrates how to connect to an OLEDB (ADO) data source,
    change the data source, and change the database by using the ConnectionProperty Object,
    as well as how to change the table name by using the Location property of the DatabaseTable Object.
    CrystalReport1 is created using an ODBC data source connected to the pubs database on
    Microsoft SQL Server.
    The report is based off the authors table.

    Code:
    ' Create a new instance of the report.
    Dim Report As New CrystalReport1
    
    Private Sub Form_Load()
    
      ' Declare a ConnectionProperty object.
      Dim CPProperty As CRAXDRT.ConnectionProperty
      
      ' Declare a DatabaseTable object.
      Dim DBTable As CRAXDRT.DatabaseTable
    
      ' Get the first table in the report.
      Set DBTable = Report.Database.Tables(1)
    
      ' Get the "Data Source" property from the ConnectionProperties collection.
      Set CPProperty = DBTable.ConnectionProperties("Data Source")
    
      ' Set the new data source (server name).
      ' Note: You do not need to set this property if you are using the same data source.
      CPProperty.Value = "Server2"
    
      ' Get the "User ID" property from the ConnectionProperties collection.
      Set CPProperty = DBTable.ConnectionProperties("User ID")
    
      ' Set the user name.
      ' Note: You do not need to set this property if you are using the same user name.
      CPProperty.Value = "UserName"
    
      ' Get the "Password" property from the ConnectionProperties collection.
      Set CPProperty = DBTable.ConnectionProperties("Password")
    
      ' Set the password.
      ' Note: You must always set the password if one is required.
      CPProperty.Value = "Password"
    
      ' Get the "Initial Catalog" (database name) property from the ConnectionProperties collection.
      ' Note: You do not need to set this property if you are using the same database.
      Set CPProperty = DBTable.ConnectionProperties("Initial Catalog")
    
      ' Set the new database name.
      CPProperty.Value = "master"
    
      ' Set the new table name.
      DBTable.Location = "authors2"
    
      ' Set the report source of the viewer and view the report.
      CRViewer91.ReportSource = Report
      CRViewer91.ViewReport
      Screen.MousePointer = vbDefault
    
    End Sub
    Hope this help
    JG

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

Featured