Why am I getting a "Database Login Failure" in Crystal Reports when using a .NET object as a data source?

I am creating a simple report using the .NET object from my project as a data source using a method SetDatasource(). However, when I run the report, I get the error "Error logging into the database." This report does not connect to the database at all - did I miss something?

Thanks a lot, D.

ADDED: I think this will help if I enable the Controller action. This is a quick and dirty test, not what the last method will look like:

public ActionResult StewardSheets(int showId, int groupId)
{
    ReportClass rptH = new ReportClass();
    rptH.FileName = DataHelper.getReportFilePath("Test.rpt",this);

    NZDSDataContext dataContext = new NZDSDataContext();
    var showDetails = (from s in dataContext.Shows
                       where s.ID == showId
                       select new StewardSheetModel
                       {
                           EventDate = s.EventDate.ToLongDateString(),
                           Region = s.Region.Name,
                           ShowTitle = s.Name
                       }).FirstOrDefault();

    List<StewardSheetModel> details = new List<StewardSheetModel>();
    details.Add(showDetails);

    rptH.SetDataSource(details);

    rptH.Load();
    Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
    return File(stream, "application/pdf");
}

FIXED: D'o! I used ReportClass instead of ReportDocument. This line has been changed, and also use Refresh () since Load () is not a valid method. Now it works great!

+6
10

: ReportDocument ReportClass.

+1

ADO.NET DataSets , , DataSet . - > .

, , , . , .

, Customers Orders, , . , " ", .

// Create a new customer orders report.
CustomerOrdersReport report = new CustomerOrdersReport();

// Get the report data.
DataTable customersTable = getCustomersData();
DataTable ordersTable = getOrdersData();

// Set datasources.
report.Database.Tables["Customers"].SetDataSource(customersTable);
report.Database.Tables["Orders"].SetDataSource(ordersTable ); // Don't forget this line like I did!!
+8

, Report → Database- > Verify Database.

, DataSet.xsd(, DataSet1.xsd) Apply.

.

+4

, .NET, . , , .Net, . .

+2

. .NET webforms, CrystalReportViewer Crystal Report. " " .

RPT Crystal Report Designer Database -> Verify Database

enter image description here

. !!!

enter image description here

XSD, BOOM

+2

datatable. -

rpt.Database.Tables( " " ). SetDataSource (CType (DataSource.Account, DataTable))

0

10.

0
source

, " "

CrystalDecisions.Shared.TableLogOnInfo li;
li.ConnectionInfo.IntegratedSecurity = false;
0
source

" " Windows Server 2016 Windows Server 2018 . Visual Studio 2017 , IIS Windows Server 2016 .

After a day of research, I installed the Microsoft OLE DB driver for SQL Server on my development computer - https://docs.microsoft.com/en-us/sql/connect/oledb/oledb-driver-for-sql-server? view = sql-server-2017. Crystal Report MSOLEDBSQL. Microsoft OLE DB SQL Server Windows Server 2016.

It turns out that Microsoft decided to abandon the Microsoft OLE DB provider for SQL Server. This and the native client no longer work with Crystal Reports.

0
source

Mine did this when I sent a DataSet instead of a DataTable.

ReportDocument.SetDataSource (dataset.Tables [0]);

0
source

All Articles