Why do I get “Database logon failed” in Crystal Reports when using .NET object as datasource?

后端 未结 12 2284
故里飘歌
故里飘歌 2020-12-29 14:45

I am creating a simple report using a .NET object from my project as datasource, using SetDatasource() method. However, when I run the report I get \"Database l

12条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 15:16

    I hade the same problem and it was due to the fact that I accidentally added anoher DataTable with the same name.

    var ds = new OrderDetail();
    var dt = new OrderDetail.ResultDataTable();
    //fill dataset here
    ds.Tables.Add(dt);
    

    After setting that DataSet as datasource I got the login failed error when exporting the report.

    I then added a line to remove the DataTable before adding the new DataTable:

    ds.Tables.Remove(dt.TableName);
    

提交回复
热议问题