Crystal Report in runtime

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

    #1

    Crystal Report in runtime

    How can i use Crystal repors without knowing which database and table will be
    used.
    For example after any SQL query?
    thanks
  • eye5600

    #2
    RE: Crystal Report in runtime

    Base your Crystal report on a dataset. At runtime, you can use any data set
    that is properly populated. You ill need to include code to tell the the
    report how to talk to the new database, e.g.
    sda.Fill(dsRpt, "ach_log");
    AchLogEntry oRpt = new AchLogEntry() ;

    //Boilerplate possibly required to change databases.
    Database d ;
    Tables c;
    Table t ;
    TableLogOnInfo ti = new TableLogOnInfo( ) ;
    ConnectionInfo ci = new ConnectionInfo( ) ;
    ci.ServerName = LoginPW.Server ;
    ci.DatabaseName = LoginPW.Databas e;
    ci.UserID = LoginPW.LoginID ;
    ci.Password = LoginPW.Passwor d;
    d = oRpt.Database ;
    c = d.Tables ;
    for (int i=0; i<c.Count; i++)
    {
    t = c[i] ;
    ti = t.LogOnInfo ;
    ti.ConnectionIn fo = ci ;
    t.ApplyLogOnInf o(ti) ;
    string s = LoginPW.Databas e+".dbo." +
    t.Location.Subs tring(t.Locatio n.LastIndexOf(" .")+1) ;
    t.Location = s;
    }

    oRpt.SetDataSou rce(dsRpt) ;
    crViewer.Report Source = oRpt ;

    "MAT" wrote:
    [color=blue]
    > How can i use Crystal repors without knowing which database and table will be
    > used.
    > For example after any SQL query?
    > thanks[/color]

    Comment

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

      #3
      Re: Crystal Report in runtime

      Hi,

      Use the push method, simply is using a dataset as the datasource, now the
      only trick is that you need the dataset schema before create the report ,
      just run your SP dump it in a dataset and write the schema
      later you browse for this file in the CR designer, later at runtime you do a
      ReportDocument. SetDataSource( theDataSet);

      cheers,

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



      "MAT" <MAT@discussion s.microsoft.com > wrote in message
      news:8453CC5C-62C5-489E-AFD8-E0DF4E3F5DA8@mi crosoft.com...[color=blue]
      > How can i use Crystal repors without knowing which database and table will
      > be
      > used.
      > For example after any SQL query?
      > thanks[/color]


      Comment

      Working...