Search code examples
c#winformscrystal-reportscrystal-reports-xicrystal-reports-2010

Database Login UserName Password window appeared on view of Crystal report VS2010 with two .ttx file


I am working on C# 4.0 Win-Form application and using Crystal Report For VS2010. In my report i have connection with Field Definition Only File. I have two ".ttx" files.

When I view my report it asks login, UserName and password for second file. For Example :

I have two ttx files. MastTable.ttx, DetaTable.ttx

Code is as:

DataTable A, B;
A.TableName = "MastTable"
B.TableName = "DetaTable"
DataSet D = new DataSet()
D.AddRange(new DataTable[] { A, B } );

MyReport Rep = new MyReport();
Rep.SetDataSource(D);

CrRepViewer.ReportSource = MyReport;

Here on view Database login UserName Password window appear for DetaTable.ttx

How can I resolve it?


Solution

  • I tried this type of pairing of data tables in my code.

    rpt is object of my report. ds is dataset.

    rpt.Database.Tables("MastTable").SetDataSource(ds.Tables("MastTable"))
    rpt.Database.Tables("DetaTable").SetDataSource(ds.Tables("DetaTable"))
    

    if you have sub-reports, then try this,

    rpt.Subreports(0).Database.Tables("Table1").SetDataSource(ds.Tables("YourTableName"))