简单的linq2sql查询显示在水晶报表中 [英] Simple linq2sql query to display in crystal report

查看:310
本文介绍了简单的linq2sql查询显示在水晶报表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是水晶报表的新手,并且希望使用linq2sql在水晶报表上显示sql数据。到目前为止,我只是试图显示一个字段(tripNo)没有运气。我的错误是数据源对象无效。这里是我的代码。

I am new to crystal reports and would like to to display sql data on a crystal report using linq2sql. So far i am just trying to display one field (tripNo) with no luck. My error is the data source object is invalid. Here is my code.

private void runstuff()
    {
        using (DataClasses1DataContext db = new DataClasses1DataContext())
        {
            var test = (from s in db.trips
                        select s.tripNo).First();

            CrystalReport1 cr1 = new CrystalReport1();
            cr1.SetDataSource(test);
            crystalReportViewer1.ReportSource = cr1;
        }
    }


推荐答案

app.config文件需要此行

The app.config file needed this line

<startup useLegacyV2RuntimeActivationPolicy="true">

这篇关于简单的linq2sql查询显示在水晶报表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆