首页 \ 问答 \ 在VB.Net中手动在Reportviewer中加载.rdlc报告(Loading .rdlc report in Reportviewer manually in VB.Net)

在VB.Net中手动在Reportviewer中加载.rdlc报告(Loading .rdlc report in Reportviewer manually in VB.Net)

我需要在reportviewer中提供认真的帮助。
我看了很多链接,各方面尝试了很多代码,但找不到合适的解决方案。 请让我理解并清除我的怀疑。
完全混淆了在代码中选择哪个数据集以及什么是datasource.value每次都给我错误的东西......

我正在展示如何创建报告并尝试使其工作的步骤。 这是因为我可能在创建报告时犯了任何错误,而人们可能会抓住它。

现在问题如下所述,我有很多.rdlc报告我的项目。 我做的是

注意:包含表单名称的Reportviewer是Reports.vb
RDLC报告是Reports1.rdlc,Report2.rdlc,......

1)创建报告,如添加 - >新项目 - >报告 - >报告 - > Report1.rdlc
报告名称:Report1.rdlc

2)然后我像这样从这里添加数据集......

在此处输入图像描述

3)打开DataSet属性,它甚至打开DataSource配置向导。 我选择存储过程,因为我想从我的存储过程中获取数据并按下Finish。
这里DataSet Name是BonnyDataSet

在此处输入图像描述

4)之后,我从数据集属性中选择数据源...
现在这里的可用数据集是什么????
在ReportViewer中加载时我必须考虑哪个数据集?

在此处输入图像描述

5)现在我通过添加下面显示的dataset1的数据列来组织列...

在此处输入图像描述

6)现在我以Reports.vb的形式添加了Reportviewer并尝试了很多代码....
在这里展示他们中的一些。

Private Sub Reports_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            'Select Case PubRepVar
            'Case "AccMast"
            Dim data As New BonnyDataSet
            Dim rds = New ReportDataSource("BonnyDataSet", data)
            ReportViewer.LocalReport.DataSources.Clear()
            ReportViewer.LocalReport.DataSources.Add(rds)   ‘------error here
            ReportViewer.LocalReport.ReportEmbeddedResource = "YourProjectNamespace.Report1.rdlc"
            ReportViewer.RefreshReport()
            'End Select

        Catch ex As Exception
            MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

我收到如下错误:

BC30311:“ReportDataSource”类型的值无法转换为“ReportDataSource”

我对这个错误一无所知。

我尝试的另一个代码是ReportViewer.ProcessingMode = ProcessingMode.Local

        Dim localReport As LocalReport
        localReport = ReportViewer.LocalReport ‘-------error here

        localReport.ReportEmbeddedResource =
            "ReportViewerIntro.Report1.rdlc"

        Dim dataset As New DataSet("BonnyDataSet")

这里的错误显示如下:

BC30311:“LocalReport”类型的值无法转换为“LocalReport”。

我尝试了很多其他但却无法理解问题所在。 我在创建.rdlc报告时做错了什么?

迫切需要帮助。 感谢名单


I need a serious help in reportviewer.
I seen a lot links, tried a lot codes every way but cannot find a proper solution. Please make me understand and clear my doubts even.
Totally confused which dataset to select during code and what is datasource.value thing which gives me error everytime...

I am showing the steps how I created the report and trying to make it work. This because I might have done any mistake in creating the reports and you people may catch it.

Now the problem is described below, I have many .rdlc reporting my project. What I done is

Note : Reportviewer containing form name is Reports.vb
RDLC reports are Reports1.rdlc,Report2.rdlc,...

1) Created Report like Add -> New Item -> Reporting -> Report -> Report1.rdlc
Report Name: Report1.rdlc

2) Then I add dataset from here like this …

enter image description here

3) DataSet properties opens, it even opens DataSource configuration Wizard. I select stored procedures because I want to fetch data from my stored procedures and pressed Finish.
Here DataSet Name is BonnyDataSet

enter image description here

4) After that, I select data source from dataset properties…
Now what is this Available datasets here in the last…???
And which dataset I have to consider during loading in ReportViewer???

enter image description here

5) Now I organised the column by adding the data columns from dataset1 shown below…

enter image description here

6) Now I added Reportviewer in form Reports.vb and tried a lot of codes….
Showing some of them here.

Private Sub Reports_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            'Select Case PubRepVar
            'Case "AccMast"
            Dim data As New BonnyDataSet
            Dim rds = New ReportDataSource("BonnyDataSet", data)
            ReportViewer.LocalReport.DataSources.Clear()
            ReportViewer.LocalReport.DataSources.Add(rds)   ‘------error here
            ReportViewer.LocalReport.ReportEmbeddedResource = "YourProjectNamespace.Report1.rdlc"
            ReportViewer.RefreshReport()
            'End Select

        Catch ex As Exception
            MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

I get the error as following:

BC30311 : Value of type 'ReportDataSource' cannot be converted to 'ReportDataSource'

I have no Idea on this error.

Another code I tried is ReportViewer.ProcessingMode = ProcessingMode.Local

        Dim localReport As LocalReport
        localReport = ReportViewer.LocalReport ‘-------error here

        localReport.ReportEmbeddedResource =
            "ReportViewerIntro.Report1.rdlc"

        Dim dataset As New DataSet("BonnyDataSet")

Here error shows like :

BC30311 : Value of type 'LocalReport' cannot be converted to 'LocalReport'.

And I tried many other but can’t understand what the problem is. Am I doing something wrong during the creation of .rdlc reports???

Needed help eagerly. Thanx


原文:https://stackoverflow.com/questions/40056855
更新时间:2022-10-18 19:10

最满意答案

C中主函数的签名是这样的:

int main(int argc, char *argv[]);

argc是传递给程序的参数数量,包括程序名称。

argv是一个数组,包含每个参数作为字符串。

所以如果你这样调用你的程序:

./program 10

argc将是2

argv [0]将是字符串'program'

argv [1]将是字符串'10'

您可以像这样修复您的代码:

#include <stdio.h>
#include <stdlib.h>
#define PI 3.1416
int
main (int argc, char *argv[])

{
  double r,area, circ;

  char *a = argv[1];
  int num = atoi(a);

  printf("You have entered %d",num);

  r= num/2;
  area = PI * r * r;
  circ= 2 * PI * r;

  printf ("A circle with a diameter of %d ", num);
  printf ("has an area of %5.3lf cm2\n", area);
  printf ("and a circumference of %4.2lf cm.\n", circ);

  return (0);

}

您可能还想在print语句中添加换行符。


The signature for the main function in C would be this:

int main(int argc, char *argv[]);

argc is the number of arguments passed to your program, including the program name its self.

argv is an array containing each argument as a string of characters.

So if you invoked your program like this:

./program 10

argc would be 2

argv[0] would be the string program

argv[1] would be the string 10

You could fix your code like this:

#include <stdio.h>
#include <stdlib.h>
#define PI 3.1416
int
main (int argc, char *argv[])

{
  double r,area, circ;

  char *a = argv[1];
  int num = atoi(a);

  printf("You have entered %d",num);

  r= num/2;
  area = PI * r * r;
  circ= 2 * PI * r;

  printf ("A circle with a diameter of %d ", num);
  printf ("has an area of %5.3lf cm2\n", area);
  printf ("and a circumference of %4.2lf cm.\n", circ);

  return (0);

}

You probably also want to add line breaks into your print statements for readability.

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。