在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.rdlc3)打开DataSet属性,它甚至打开DataSource配置向导。 我选择存储过程,因为我想从我的存储过程中获取数据并按下Finish。
这里DataSet Name是BonnyDataSet4)之后,我从数据集属性中选择数据源...
现在这里的可用数据集是什么????
在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.rdlc2) Then I add dataset from here like this …
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 BonnyDataSet4) 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???5) Now I organised the column by adding the data columns from dataset1 shown below…
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
最满意答案
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 be2
argv[0]
would be the stringprogram
argv[1]
would be the string10
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.
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
程序的参数总是字符串。 int exec_arg_1, exec_arg_2; if (pid == 0){ printf("Repeat Number: %d, Process Number: %d\n", exec_arg_1, exec_arg_2); char arg1[20], arg2[20]; snprintf(arg1, sizeof(arg1), "%d", exec_arg_1); snprintf(arg2, sizeof(arg2), "%d", e ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
右键单击解决方案资源管理器中的项目,然后从菜单中选择属性 转到配置属性 - >调试 在属性列表中设置命令参数。 Right click your project in Solution Explorer and select Properties from the menu Go to Configuration Properties -> Debugging Set the Command Arguments in the property list.
-
传递*作为命令行参数(Passing * as a command line argument)[2022-01-19]
你需要逃避*例如引用它像"*"或通过像\*一样转义它 *的扩展由shell完成(在启动程序之前)。 阅读例如Advanced Bash Scripting指南 。 You need to escape the * e.g. by quoting it like "*" or by escaping it like \* The expansion of * is done by the shell (before starting your program). Read e.g. the Advanced ... -
将python中的字典值作为命令行输入传递给c ++代码(Passing dictionary values in python as command line inputs to c++ code)[2023-12-21]
除非你放松其中一个限制,否则你不能这样做。 放宽python dict要求:命令行有一个定义良好的文本参数接口,可以轻松处理所有信息。 您可以传递json文件名,dict的str表示,或传递名称 - 值对作为命令行参数。 放宽系统调用要求:您可以构建python c ++扩展,而不是从c ++代码构建可执行文件。 c ++代码可以导出带有python dict的函数。 放宽c ++的要求:显然你可以在python中编写代码。 You can't do that unless you relax one of ... -
*argv[i+1] 访问char* argv[]参数的第一个char。 为了获得全部价值,请使用类似的东西 std::string filename(argv[i+1]); 代替。 *argv[i+1] Accesses the 1st char of the char* argv[] argument. To get the whole value use something like std::string filename(argv[i+1]); instead.
-
当您引用argv[1] ,它引用包含值123的字符数组。 isdigit函数是为单个字符输入定义的。 所以要处理这种情况,最好定义一个函数如下: bool isNumber(char number[]) { int i = 0; //checking for negative numbers if (number[0] == '-') i = 1; for (; number[i] != 0; i++) { //if (number[ ...
-
我如何编写一个从命令行获取整数的C程序?(How could I write a C program that takes an integer from command line?)[2022-08-24]
#include#include int main(int argc, char * argv[]) { int n = atoi(argv[1]); // n from command line n = n + 1; // return n + 1 printf("%d", n); return 0; } #include #include int main(int arg ... -
C中主函数的签名是这样的: int main(int argc, char *argv[]); argc是传递给程序的参数数量,包括程序名称。 argv是一个数组,包含每个参数作为字符串。 所以如果你这样调用你的程序: ./program 10 argc将是2 argv [0]将是字符串'program' argv [1]将是字符串'10' 您可以像这样修复您的代码: #include
#include #define PI 3.1416 int main (i ...