Access and Crystal Reports

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alberto

    Access and Crystal Reports

    My application uses Access and I have some reports. The problem is that when
    I design the reports, I use the path of the database in my machine but in
    the customer it will not be the same. How can I solve this?

    Thank you very much


  • Ignacio Machin \( .NET/ C# MVP \)

    #2
    Re: Access and Crystal Reports

    Hi,

    You have to setup the correct info, the below code works fine with a SQL DB:


    TableLogOnInfos crTableLogonInf os = new TableLogOnInfos ();
    reportDocument1 = new OpenRecords();

    ConnectionInfo crConnectionInf o = new ConnectionInfo( );
    crConnectionInf o.ServerName =
    System.Configur ation.Configura tionSettings.Ap pSettings["Server"];
    crConnectionInf o.DatabaseName =
    System.Configur ation.Configura tionSettings.Ap pSettings["DataBase"] ;
    crConnectionInf o.UserID =
    System.Configur ation.Configura tionSettings.Ap pSettings["User"] ;
    crConnectionInf o.Password =
    System.Configur ation.Configura tionSettings.Ap pSettings["Password"] ;

    foreach (CrystalDecisio ns.CrystalRepor ts.Engine.Table table in
    reportDocument1 .Database.Table s)
    {
    TableLogOnInfo crTableLogonInf o = new TableLogOnInfo( );
    crTableLogonInf o.TableName = table.Name;
    crTableLogonInf o.ConnectionInf o = crConnectionInf o;
    crTableLogonInf os.Add( crTableLogonInf o);
    table.ApplyLogO nInfo( crTableLogonInf o);

    }
    CrystalReportVi ewer1.LogOnInfo = crTableLogonInf os;


    Cheers,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation





    "Alberto" <alberto@nospam .com> wrote in message
    news:OF6R92plFH A.1464@TK2MSFTN GP14.phx.gbl...[color=blue]
    > My application uses Access and I have some reports. The problem is that
    > when I design the reports, I use the path of the database in my machine
    > but in the customer it will not be the same. How can I solve this?
    >
    > Thank you very much
    >[/color]


    Comment

    • Ignacio Machin \( .NET/ C# MVP \)

      #3
      Re: Access and Crystal Reports

      Hi,

      This is the code you have to add, you need to change the report LogonInfo ,
      as well as the logonInfo of the tables of the report.

      // This is the form
      frmReports frm = new frmReports();

      // Logon info
      TableLogOnInfos crTableLogonInf os = new TableLogOnInfos ();
      //Create the report
      ReportDocument reportDocument1 = new Reports.MyRepor t();

      //Get the data from the DB
      // Change this to put the connection string elements
      ConnectionInfo crConnectionInf o = new ConnectionInfo( );
      crConnectionInf o.ServerName =
      System.Configur ation.Configura tionSettings.Ap pSettings["Server"];
      crConnectionInf o.DatabaseName =
      System.Configur ation.Configura tionSettings.Ap pSettings["DataBase"] ;
      crConnectionInf o.UserID =
      System.Configur ation.Configura tionSettings.Ap pSettings["User"] ;
      crConnectionInf o.Password =
      System.Configur ation.Configura tionSettings.Ap pSettings["Password"] ;


      //Update the info in the tables of the report
      foreach (CrystalDecisio ns.CrystalRepor ts.Engine.Table table in
      reportDocument1 .Database.Table s)
      {
      TableLogOnInfo crTableLogonInf o = new TableLogOnInfo( );
      crTableLogonInf o.TableName = table.Name;
      crTableLogonInf o.ConnectionInf o = crConnectionInf o;
      crTableLogonInf os.Add( crTableLogonInf o);
      table.ApplyLogO nInfo( crTableLogonInf o);

      }
      //
      frm.CrystalRepo rtsViewer.LogOn Info = crTableLogonInf os;
      frm.CrystalRepo rtsViewer.Repor tSource = reportDocument1 ;
      frm.ShowDialog( )



      cheers,




      "Alberto" <alberto@nospam .com> wrote in message
      news:uiZVvlqlFH A.3568@tk2msftn gp13.phx.gbl...[color=blue]
      > Sorry but I don't understand your code. What I'm doing actually to see the
      > preview of a report is this:
      >
      > frmReports frm = new frmReports();
      > frm.CrystalRepo rtsViewer.Repor tSource = new Reports.MyRepor t();
      > frm.ShowDialog( );
      >
      >
      > "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
      > escribió en el mensaje news:uWeoVTqlFH A.3568@tk2msftn gp13.phx.gbl...[color=green]
      >> Hi,
      >>
      >> You have to setup the correct info, the below code works fine with a SQL
      >> DB:
      >>
      >>
      >> TableLogOnInfos crTableLogonInf os = new TableLogOnInfos ();
      >> reportDocument1 = new OpenRecords();
      >>
      >> ConnectionInfo crConnectionInf o = new ConnectionInfo( );
      >> crConnectionInf o.ServerName =
      >> System.Configur ation.Configura tionSettings.Ap pSettings["Server"];
      >> crConnectionInf o.DatabaseName =
      >> System.Configur ation.Configura tionSettings.Ap pSettings["DataBase"] ;
      >> crConnectionInf o.UserID =
      >> System.Configur ation.Configura tionSettings.Ap pSettings["User"] ;
      >> crConnectionInf o.Password =
      >> System.Configur ation.Configura tionSettings.Ap pSettings["Password"] ;
      >>
      >> foreach (CrystalDecisio ns.CrystalRepor ts.Engine.Table table in
      >> reportDocument1 .Database.Table s)
      >> {
      >> TableLogOnInfo crTableLogonInf o = new TableLogOnInfo( );
      >> crTableLogonInf o.TableName = table.Name;
      >> crTableLogonInf o.ConnectionInf o = crConnectionInf o;
      >> crTableLogonInf os.Add( crTableLogonInf o);
      >> table.ApplyLogO nInfo( crTableLogonInf o);
      >>
      >> }
      >> CrystalReportVi ewer1.LogOnInfo = crTableLogonInf os;
      >>
      >>
      >> Cheers,
      >>
      >> --
      >> Ignacio Machin,
      >> ignacio.machin AT dot.state.fl.us
      >> Florida Department Of Transportation
      >>
      >>
      >>
      >>
      >>
      >> "Alberto" <alberto@nospam .com> wrote in message
      >> news:OF6R92plFH A.1464@TK2MSFTN GP14.phx.gbl...[color=darkred]
      >>> My application uses Access and I have some reports. The problem is that
      >>> when I design the reports, I use the path of the database in my machine
      >>> but in the customer it will not be the same. How can I solve this?
      >>>
      >>> Thank you very much
      >>>[/color]
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • Alberto

        #4
        Re: Access and Crystal Reports

        Thank you very much.

        "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
        escribió en el mensaje news:ucJiZwrlFH A.576@TK2MSFTNG P15.phx.gbl...[color=blue]
        > Hi,
        >
        > This is the code you have to add, you need to change the report LogonInfo
        > , as well as the logonInfo of the tables of the report.
        >
        > // This is the form
        > frmReports frm = new frmReports();
        >
        > // Logon info
        > TableLogOnInfos crTableLogonInf os = new TableLogOnInfos ();
        > //Create the report
        > ReportDocument reportDocument1 = new Reports.MyRepor t();
        >
        > //Get the data from the DB
        > // Change this to put the connection string elements
        > ConnectionInfo crConnectionInf o = new ConnectionInfo( );
        > crConnectionInf o.ServerName =
        > System.Configur ation.Configura tionSettings.Ap pSettings["Server"];
        > crConnectionInf o.DatabaseName =
        > System.Configur ation.Configura tionSettings.Ap pSettings["DataBase"] ;
        > crConnectionInf o.UserID =
        > System.Configur ation.Configura tionSettings.Ap pSettings["User"] ;
        > crConnectionInf o.Password =
        > System.Configur ation.Configura tionSettings.Ap pSettings["Password"] ;
        >
        >
        > //Update the info in the tables of the report
        > foreach (CrystalDecisio ns.CrystalRepor ts.Engine.Table table in
        > reportDocument1 .Database.Table s)
        > {
        > TableLogOnInfo crTableLogonInf o = new TableLogOnInfo( );
        > crTableLogonInf o.TableName = table.Name;
        > crTableLogonInf o.ConnectionInf o = crConnectionInf o;
        > crTableLogonInf os.Add( crTableLogonInf o);
        > table.ApplyLogO nInfo( crTableLogonInf o);
        >
        > }
        > //
        > frm.CrystalRepo rtsViewer.LogOn Info = crTableLogonInf os;
        > frm.CrystalRepo rtsViewer.Repor tSource = reportDocument1 ;
        > frm.ShowDialog( )
        >
        >
        >
        > cheers,
        >
        >
        >
        >
        > "Alberto" <alberto@nospam .com> wrote in message
        > news:uiZVvlqlFH A.3568@tk2msftn gp13.phx.gbl...[color=green]
        >> Sorry but I don't understand your code. What I'm doing actually to see
        >> the preview of a report is this:
        >>
        >> frmReports frm = new frmReports();
        >> frm.CrystalRepo rtsViewer.Repor tSource = new Reports.MyRepor t();
        >> frm.ShowDialog( );
        >>
        >>
        >> "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
        >> escribió en el mensaje news:uWeoVTqlFH A.3568@tk2msftn gp13.phx.gbl...[color=darkred]
        >>> Hi,
        >>>
        >>> You have to setup the correct info, the below code works fine with a SQL
        >>> DB:
        >>>
        >>>
        >>> TableLogOnInfos crTableLogonInf os = new TableLogOnInfos ();
        >>> reportDocument1 = new OpenRecords();
        >>>
        >>> ConnectionInfo crConnectionInf o = new ConnectionInfo( );
        >>> crConnectionInf o.ServerName =
        >>> System.Configur ation.Configura tionSettings.Ap pSettings["Server"];
        >>> crConnectionInf o.DatabaseName =
        >>> System.Configur ation.Configura tionSettings.Ap pSettings["DataBase"] ;
        >>> crConnectionInf o.UserID =
        >>> System.Configur ation.Configura tionSettings.Ap pSettings["User"] ;
        >>> crConnectionInf o.Password =
        >>> System.Configur ation.Configura tionSettings.Ap pSettings["Password"] ;
        >>>
        >>> foreach (CrystalDecisio ns.CrystalRepor ts.Engine.Table table in
        >>> reportDocument1 .Database.Table s)
        >>> {
        >>> TableLogOnInfo crTableLogonInf o = new TableLogOnInfo( );
        >>> crTableLogonInf o.TableName = table.Name;
        >>> crTableLogonInf o.ConnectionInf o = crConnectionInf o;
        >>> crTableLogonInf os.Add( crTableLogonInf o);
        >>> table.ApplyLogO nInfo( crTableLogonInf o);
        >>>
        >>> }
        >>> CrystalReportVi ewer1.LogOnInfo = crTableLogonInf os;
        >>>
        >>>
        >>> Cheers,
        >>>
        >>> --
        >>> Ignacio Machin,
        >>> ignacio.machin AT dot.state.fl.us
        >>> Florida Department Of Transportation
        >>>
        >>>
        >>>
        >>>
        >>>
        >>> "Alberto" <alberto@nospam .com> wrote in message
        >>> news:OF6R92plFH A.1464@TK2MSFTN GP14.phx.gbl...
        >>>> My application uses Access and I have some reports. The problem is that
        >>>> when I design the reports, I use the path of the database in my machine
        >>>> but in the customer it will not be the same. How can I solve this?
        >>>>
        >>>> Thank you very much
        >>>>
        >>>
        >>>[/color]
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Alberto

          #5
          Re: Access and Crystal Reports

          I tried it but there is an error in ReportDocument.
          If the database is access witch is the sever and the database?
          Thank you

          "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
          escribió en el mensaje news:ucJiZwrlFH A.576@TK2MSFTNG P15.phx.gbl...[color=blue]
          > Hi,
          >
          > This is the code you have to add, you need to change the report LogonInfo
          > , as well as the logonInfo of the tables of the report.
          >
          > // This is the form
          > frmReports frm = new frmReports();
          >
          > // Logon info
          > TableLogOnInfos crTableLogonInf os = new TableLogOnInfos ();
          > //Create the report
          > ReportDocument reportDocument1 = new Reports.MyRepor t();
          >
          > //Get the data from the DB
          > // Change this to put the connection string elements
          > ConnectionInfo crConnectionInf o = new ConnectionInfo( );
          > crConnectionInf o.ServerName =
          > System.Configur ation.Configura tionSettings.Ap pSettings["Server"];
          > crConnectionInf o.DatabaseName =
          > System.Configur ation.Configura tionSettings.Ap pSettings["DataBase"] ;
          > crConnectionInf o.UserID =
          > System.Configur ation.Configura tionSettings.Ap pSettings["User"] ;
          > crConnectionInf o.Password =
          > System.Configur ation.Configura tionSettings.Ap pSettings["Password"] ;
          >
          >
          > //Update the info in the tables of the report
          > foreach (CrystalDecisio ns.CrystalRepor ts.Engine.Table table in
          > reportDocument1 .Database.Table s)
          > {
          > TableLogOnInfo crTableLogonInf o = new TableLogOnInfo( );
          > crTableLogonInf o.TableName = table.Name;
          > crTableLogonInf o.ConnectionInf o = crConnectionInf o;
          > crTableLogonInf os.Add( crTableLogonInf o);
          > table.ApplyLogO nInfo( crTableLogonInf o);
          >
          > }
          > //
          > frm.CrystalRepo rtsViewer.LogOn Info = crTableLogonInf os;
          > frm.CrystalRepo rtsViewer.Repor tSource = reportDocument1 ;
          > frm.ShowDialog( )
          >
          >
          >
          > cheers,
          >
          >
          >
          >
          > "Alberto" <alberto@nospam .com> wrote in message
          > news:uiZVvlqlFH A.3568@tk2msftn gp13.phx.gbl...[color=green]
          >> Sorry but I don't understand your code. What I'm doing actually to see
          >> the preview of a report is this:
          >>
          >> frmReports frm = new frmReports();
          >> frm.CrystalRepo rtsViewer.Repor tSource = new Reports.MyRepor t();
          >> frm.ShowDialog( );
          >>
          >>
          >> "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
          >> escribió en el mensaje news:uWeoVTqlFH A.3568@tk2msftn gp13.phx.gbl...[color=darkred]
          >>> Hi,
          >>>
          >>> You have to setup the correct info, the below code works fine with a SQL
          >>> DB:
          >>>
          >>>
          >>> TableLogOnInfos crTableLogonInf os = new TableLogOnInfos ();
          >>> reportDocument1 = new OpenRecords();
          >>>
          >>> ConnectionInfo crConnectionInf o = new ConnectionInfo( );
          >>> crConnectionInf o.ServerName =
          >>> System.Configur ation.Configura tionSettings.Ap pSettings["Server"];
          >>> crConnectionInf o.DatabaseName =
          >>> System.Configur ation.Configura tionSettings.Ap pSettings["DataBase"] ;
          >>> crConnectionInf o.UserID =
          >>> System.Configur ation.Configura tionSettings.Ap pSettings["User"] ;
          >>> crConnectionInf o.Password =
          >>> System.Configur ation.Configura tionSettings.Ap pSettings["Password"] ;
          >>>
          >>> foreach (CrystalDecisio ns.CrystalRepor ts.Engine.Table table in
          >>> reportDocument1 .Database.Table s)
          >>> {
          >>> TableLogOnInfo crTableLogonInf o = new TableLogOnInfo( );
          >>> crTableLogonInf o.TableName = table.Name;
          >>> crTableLogonInf o.ConnectionInf o = crConnectionInf o;
          >>> crTableLogonInf os.Add( crTableLogonInf o);
          >>> table.ApplyLogO nInfo( crTableLogonInf o);
          >>>
          >>> }
          >>> CrystalReportVi ewer1.LogOnInfo = crTableLogonInf os;
          >>>
          >>>
          >>> Cheers,
          >>>
          >>> --
          >>> Ignacio Machin,
          >>> ignacio.machin AT dot.state.fl.us
          >>> Florida Department Of Transportation
          >>>
          >>>
          >>>
          >>>
          >>>
          >>> "Alberto" <alberto@nospam .com> wrote in message
          >>> news:OF6R92plFH A.1464@TK2MSFTN GP14.phx.gbl...
          >>>> My application uses Access and I have some reports. The problem is that
          >>>> when I design the reports, I use the path of the database in my machine
          >>>> but in the customer it will not be the same. How can I solve this?
          >>>>
          >>>> Thank you very much
          >>>>
          >>>
          >>>[/color]
          >>
          >>[/color]
          >
          >[/color]


          Comment

          • Ignacio Machin \( .NET/ C# MVP \)

            #6
            Re: Access and Crystal Reports

            Hi,

            Humm, good question :)

            Frankly I dont know the answer, you better check in the CR forums, there I
            usually find the answer to my problems.


            cheers,

            --
            Ignacio Machin,
            ignacio.machin AT dot.state.fl.us
            Florida Department Of Transportation



            "Alberto" <alberto@nospam .com> wrote in message
            news:%23BLFUFul FHA.3380@TK2MSF TNGP10.phx.gbl. ..[color=blue]
            >I tried it but there is an error in ReportDocument.
            > If the database is access witch is the sever and the database?
            > Thank you
            >
            > "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
            > escribió en el mensaje news:ucJiZwrlFH A.576@TK2MSFTNG P15.phx.gbl...[color=green]
            >> Hi,
            >>
            >> This is the code you have to add, you need to change the report LogonInfo
            >> , as well as the logonInfo of the tables of the report.
            >>
            >> // This is the form
            >> frmReports frm = new frmReports();
            >>
            >> // Logon info
            >> TableLogOnInfos crTableLogonInf os = new TableLogOnInfos ();
            >> //Create the report
            >> ReportDocument reportDocument1 = new Reports.MyRepor t();
            >>
            >> //Get the data from the DB
            >> // Change this to put the connection string elements
            >> ConnectionInfo crConnectionInf o = new ConnectionInfo( );
            >> crConnectionInf o.ServerName =
            >> System.Configur ation.Configura tionSettings.Ap pSettings["Server"];
            >> crConnectionInf o.DatabaseName =
            >> System.Configur ation.Configura tionSettings.Ap pSettings["DataBase"] ;
            >> crConnectionInf o.UserID =
            >> System.Configur ation.Configura tionSettings.Ap pSettings["User"] ;
            >> crConnectionInf o.Password =
            >> System.Configur ation.Configura tionSettings.Ap pSettings["Password"] ;
            >>
            >>
            >> //Update the info in the tables of the report
            >> foreach (CrystalDecisio ns.CrystalRepor ts.Engine.Table table in
            >> reportDocument1 .Database.Table s)
            >> {
            >> TableLogOnInfo crTableLogonInf o = new TableLogOnInfo( );
            >> crTableLogonInf o.TableName = table.Name;
            >> crTableLogonInf o.ConnectionInf o = crConnectionInf o;
            >> crTableLogonInf os.Add( crTableLogonInf o);
            >> table.ApplyLogO nInfo( crTableLogonInf o);
            >>
            >> }
            >> //
            >> frm.CrystalRepo rtsViewer.LogOn Info = crTableLogonInf os;
            >> frm.CrystalRepo rtsViewer.Repor tSource = reportDocument1 ;
            >> frm.ShowDialog( )
            >>
            >>
            >>
            >> cheers,
            >>
            >>
            >>
            >>
            >> "Alberto" <alberto@nospam .com> wrote in message
            >> news:uiZVvlqlFH A.3568@tk2msftn gp13.phx.gbl...[color=darkred]
            >>> Sorry but I don't understand your code. What I'm doing actually to see
            >>> the preview of a report is this:
            >>>
            >>> frmReports frm = new frmReports();
            >>> frm.CrystalRepo rtsViewer.Repor tSource = new Reports.MyRepor t();
            >>> frm.ShowDialog( );
            >>>
            >>>
            >>> "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
            >>> escribió en el mensaje news:uWeoVTqlFH A.3568@tk2msftn gp13.phx.gbl...
            >>>> Hi,
            >>>>
            >>>> You have to setup the correct info, the below code works fine with a
            >>>> SQL DB:
            >>>>
            >>>>
            >>>> TableLogOnInfos crTableLogonInf os = new TableLogOnInfos ();
            >>>> reportDocument1 = new OpenRecords();
            >>>>
            >>>> ConnectionInfo crConnectionInf o = new ConnectionInfo( );
            >>>> crConnectionInf o.ServerName =
            >>>> System.Configur ation.Configura tionSettings.Ap pSettings["Server"];
            >>>> crConnectionInf o.DatabaseName =
            >>>> System.Configur ation.Configura tionSettings.Ap pSettings["DataBase"] ;
            >>>> crConnectionInf o.UserID =
            >>>> System.Configur ation.Configura tionSettings.Ap pSettings["User"] ;
            >>>> crConnectionInf o.Password =
            >>>> System.Configur ation.Configura tionSettings.Ap pSettings["Password"] ;
            >>>>
            >>>> foreach (CrystalDecisio ns.CrystalRepor ts.Engine.Table table in
            >>>> reportDocument1 .Database.Table s)
            >>>> {
            >>>> TableLogOnInfo crTableLogonInf o = new TableLogOnInfo( );
            >>>> crTableLogonInf o.TableName = table.Name;
            >>>> crTableLogonInf o.ConnectionInf o = crConnectionInf o;
            >>>> crTableLogonInf os.Add( crTableLogonInf o);
            >>>> table.ApplyLogO nInfo( crTableLogonInf o);
            >>>>
            >>>> }
            >>>> CrystalReportVi ewer1.LogOnInfo = crTableLogonInf os;
            >>>>
            >>>>
            >>>> Cheers,
            >>>>
            >>>> --
            >>>> Ignacio Machin,
            >>>> ignacio.machin AT dot.state.fl.us
            >>>> Florida Department Of Transportation
            >>>>
            >>>>
            >>>>
            >>>>
            >>>>
            >>>> "Alberto" <alberto@nospam .com> wrote in message
            >>>> news:OF6R92plFH A.1464@TK2MSFTN GP14.phx.gbl...
            >>>>> My application uses Access and I have some reports. The problem is
            >>>>> that when I design the reports, I use the path of the database in my
            >>>>> machine but in the customer it will not be the same. How can I solve
            >>>>> this?
            >>>>>
            >>>>> Thank you very much
            >>>>>
            >>>>
            >>>>
            >>>
            >>>[/color]
            >>
            >>[/color]
            >
            >[/color]


            Comment

            Working...