Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to set Datasource pointing to multiple Database at the time crystal report creation

How to set Datasource pointing to multiple Database at the time crystal report creation

Scheduled Pinned Locked Moved C#
csharpdatabasetestingbeta-testinghelp
6 Posts 4 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ajay_Chaitanya
    wrote on last edited by
    #1

    I need to create a crystal report and have to set Datasource location pointing to Development, Testing and Production servers. The created crystal report will be placed in database table and fetched at the time of reposrt generation by passing the credentials(Development or production). Please help me in this, I need a crystal report generated with multiple datasource connection. In C# I have written code as shown below:

    oReport.SetDatabaseLogon(gcUser, gcPassword, gcDB, gcDB);
    oReport.DataSourceConnections[0].SetLogon(gcUser, gcPassword);

    L J E 3 Replies Last reply
    0
    • A Ajay_Chaitanya

      I need to create a crystal report and have to set Datasource location pointing to Development, Testing and Production servers. The created crystal report will be placed in database table and fetched at the time of reposrt generation by passing the credentials(Development or production). Please help me in this, I need a crystal report generated with multiple datasource connection. In C# I have written code as shown below:

      oReport.SetDatabaseLogon(gcUser, gcPassword, gcDB, gcDB);
      oReport.DataSourceConnections[0].SetLogon(gcUser, gcPassword);

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I have no experience with Crystal Reports; but most applications will only accept a single datasource. A simple workaround is possible if you have MS Access installed; create a new Access database, and in that database, create a linked table. SQL Server can also do this trick. The basic idea is that one would build the report on the single datasource (Access or SQL) that fetches their data from linked tables (that be pointing to your other datasources).

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

      J 1 Reply Last reply
      0
      • L Lost User

        I have no experience with Crystal Reports; but most applications will only accept a single datasource. A simple workaround is possible if you have MS Access installed; create a new Access database, and in that database, create a linked table. SQL Server can also do this trick. The basic idea is that one would build the report on the single datasource (Access or SQL) that fetches their data from linked tables (that be pointing to your other datasources).

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        Pretty sure that a report accepts multiple datasources.

        L 1 Reply Last reply
        0
        • A Ajay_Chaitanya

          I need to create a crystal report and have to set Datasource location pointing to Development, Testing and Production servers. The created crystal report will be placed in database table and fetched at the time of reposrt generation by passing the credentials(Development or production). Please help me in this, I need a crystal report generated with multiple datasource connection. In C# I have written code as shown below:

          oReport.SetDatabaseLogon(gcUser, gcPassword, gcDB, gcDB);
          oReport.DataSourceConnections[0].SetLogon(gcUser, gcPassword);

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          Ajay_Chaitanya wrote:

          I need a crystal report generated with multiple datasource connection.

          Not based on what you said you don't. What you have is one datasource which needs to point to actual different sources based on the install. The most obvious and easiest way to do that would be if all of the datasources had the same name. Which realistically they should. If that isn't the case then you are going to need to provide a configuration that MUST be set when it is installed. However if reports already exist using the same database then the configuration would already exist so you would just need to find it. I would suspect, strongly, that the Crystal reports API already has a way to support this. Probably via something like a named source. But other than that .Net apps have many configuration options. So you could use one of those. If you are using that then you need to look at the process (which is not code) of installing the application on the target machine, to validate that it will get set correctly. If it was me I would also add a check that insures that 1. The datasource properties are set (configuration) 2. The datasource is accessible. That would be OUTSIDE of crystal and would use normal .Net access to the database. All it needs to do is a simple query (need not return anything.) That insures that access is set and that the app has correct permissions to access it.

          1 Reply Last reply
          0
          • J jschell

            Pretty sure that a report accepts multiple datasources.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            One would expect that, yes :)

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

            1 Reply Last reply
            0
            • A Ajay_Chaitanya

              I need to create a crystal report and have to set Datasource location pointing to Development, Testing and Production servers. The created crystal report will be placed in database table and fetched at the time of reposrt generation by passing the credentials(Development or production). Please help me in this, I need a crystal report generated with multiple datasource connection. In C# I have written code as shown below:

              oReport.SetDatabaseLogon(gcUser, gcPassword, gcDB, gcDB);
              oReport.DataSourceConnections[0].SetLogon(gcUser, gcPassword);

              E Offline
              E Offline
              eddieangel
              wrote on last edited by
              #6

              Multiple databases are really outside the scope of what CR is meant to do. That said, your best bet is to build and hydrate an object outside of Crystal Reports and set that as the datasource for the report. There are a lot of answers on the net about how to do this, just search for something along the lines of "Bind Crystal Report to object".

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups