问题设置RDLC数据源对象 [英] Issues Setting RDLC Datasource to Object

查看:819
本文介绍了问题设置RDLC数据源对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:

我一直在负责转换Access数据库应用程序ASP.Net C#MVC。这是我的第一个MVC应用程序。

有10份报告是需要转换。我们正在使用RDLC文件和的ReportViewer。我使用Visual Studio 2010中的所有最新的修补程序。我们挂接到一个已经填充由现有的Access数据库SQL Server数据库,所以表结构是石头多集,否则我们得试试10年的数据转换pretty。

我已经完成了所有,但两个报告。最后报告需要更多的处理,而不要只是从数据库中显示数据。要做到这一点,最简单的方法是创建一个C#对象,并完成所有的处理服务器端,然后使用RDLC显示结果。

问题

我遇到的问题是,Visual Studio将不承认我已经为潜在的数据源创建的对象。每次我尝试添加数据集只带来了数据源配置向导,并提供了SQL Server数据库作为可能的数据连接。我知道有一个屏幕,存在允许您选择一个对象作为数据集,但我从来没有看到屏幕。

下面是对象(为了清楚而移除处理功能):

 公共类TurnAroundVal
{
    //注册软件包信息
    公共string数据类型{搞定;组; }    //计算汇总;值只能通过构造函数或计算功能设置
    公众诠释packageCount {搞定;私人集; }
    公众诠释DAYCOUNT {搞定;组; }
    公共双avgTurnAround {搞定;私人集; }
    公众诠释upperRange {搞定;私人集; }
    公众诠释lowerRange {搞定;私人集; }
}公共类TurnAroundVals
{
    //公共变量
    公共IEnumerable的< TurnAroundVal>周转{搞定;私人集; }
    公共DatePass日期{搞定;组; }
    公众诠释pkgTotal {搞定;私人集; }
    公共双dayTotal {搞定;私人集; }
    公共双avgAl​​lTurnArounds {搞定;私人集; }
}

我也愿意用TurnAroundVal的IEnumerable的作为数据源,而只是通过日期,int和作为参数双打英寸无论是可行的。

有没有在Visual Studio 2010中我的思念,让RDLC设计师看到我创建的对象的设置?
我错了,即使想这将我定义的类工作?

所有的给出的建议是有益的,但​​最终什么让这对我的工作是建立在同一个解决方案的临时非Web项目,并创建RDLC那里。当我去添加一个数据集,它显示对象作为一个选项。你必须引用添加到您的Web项目,使你的对象是可见的,但你可以选择你想要的,并使用在RDLC。在此之后,你可以在RDLC文件拖放到你的Web项目,删除临时项目,你是好去。只要记住,你必须手动添加数据源在code,他们有被命名一样的,你在RDLC指定。


解决方案

  1. 确保类在同一个命名空间中的应用。

  2. 尝试创建报表之前构建的应用程序

  3. 启动报表向导。在DataSouce选择您的Web应用程序的名称。

  4. 在可用的数据集,你应该看到的Visual Studio间$ P $点是你的选择方法。如果一切顺利,这应该是周转。

您可能需要把在App_Data或APP_ code文件夹中的类文件,但我不能肯定。

这也是可能的帮助。

http://msdn.microsoft。 COM / EN-US /库/ ms251692%28V = VS.100%29.aspx

Background:

I've been tasked with converting an Access database application to ASP.Net C# MVC. This is my first MVC application.

There are 10 reports that need converting. We're using RDLC files and reportviewer. I'm using Visual Studio 2010 with all the most recent patches. We're hooking up to a SQL Server database that's been populated by the existing Access database, so the table structure is pretty much set in stone, or else we'll have to try to convert 10 years of data.

I've completed all but two of the reports. The final reports require more processing, and don't just display data from the database. The easiest way to do this would be to create a C# object and do all the processing server-side, then use RDLC to display the results.

Issue

The problem I'm having is that Visual Studio won't recognize the objects I've created as potential datasources. Every time I try to "add dataset" it brings up the "datasource configuration wizard" and only offers the SQL Server database as the possible data connection. I know there's a screen that exists that allows you to select an object as your dataset, but I never see that screen.

Here are the objects (processing functions removed for clarity):

public class TurnAroundVal
{
    // Registration Package information
    public string dataType { get; set; }

    // Calculated totals; values only set through constructor or calculation function
    public int packageCount { get; private set; }
    public int dayCount { get; set; }
    public double avgTurnAround { get; private set; }
    public int upperRange { get; private set; }
    public int lowerRange { get; private set; }
}

public class TurnAroundVals
{
    // Public Variables
    public IEnumerable<TurnAroundVal> TurnArounds { get; private set; }
    public DatePass dates { get; set; }
    public int pkgTotal { get; private set; }
    public double dayTotal { get; private set; }
    public double avgAllTurnArounds { get; private set; }
}

I also would be willing to use the IEnumerable of "TurnAroundVal" as a datasource, and just pass the dates, int, and doubles in as parameters. Either would work.

Question

Is there a setting in Visual Studio 2010 that I'm missing to allow the RDLC Designer to see the objects I created? Am I wrong in even thinking this will work with the classes I defined?

Answer

All of the suggestions given were helpful, but ultimately what got it to work for me was to create a temporary non-web project in the same solution and create the RDLC there. When I went to add a dataset, it shows "Objects" as an option. You have to add a reference to your web project so that your objects are visible, but then you can pick the one you want and use that in the RDLC. After that, you can just drag-drop the RDLC file into your web project, delete the temp project, and you're good to go. Just remember that you have to add the datasources manually in code, and they have to be named the same as you specified in the RDLC.

解决方案

  1. Make sure the classes are in the same namespace as the application.
  2. Try building the application before you create the report
  3. Start the report wizard. Under DataSouce select the name of your web application.
  4. Under Available Datasets you should see what Visual Studio interprets to be your "Select Method". If all is well, this should be TurnArounds.

You may need to put the class file in the App_Data or App_Code folder, but I am not certain.

This might also help.

http://msdn.microsoft.com/en-us/library/ms251692%28v=vs.100%29.aspx

这篇关于问题设置RDLC数据源对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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