ASP.NET 中对象数据源的问题(GetData 方法)
我想在 ASP.NET 中创建一个报告查看器,向用户展示他们的数据。 所有用户的数据都位于同一个表中。
现在我创建了 DBDataSet 并且在 TableAdapter 中有这个方法
GetData(@idNumber, @userNumber)
在屏幕后面的代码中,我想显示我编写的报告查看器:
FlightsDBDataSetTableAdapters.ReservationsTableAdapter ReservationsTableAdapter;
ReservationsTableAdapter = new FlightsDBDataSetTableAdapters.ReservationsTableAdapter();
FlightsDBDataSet.ReservationsDataTable newReservationTable;
newReservationTable = ReservationsTableAdapter.GetData(userId, userName);
ObjectDataSource1.SelectParameters.Add("userName", userName);
ObjectDataSource1.SelectParameters.Add("idNumber", userId);
当我运行此代码时,我收到下一个错误
报告处理期间发生错误。对象数据源 “ObjectDataSource1”找不到非泛型方法 'GetData(idNumber, userName)' 具有参数:userName、idNumber。
所以,我的问题是我需要在哪里编写 GetData 方法以及如何生成包含正确数据的报告。
多谢。
I want to create a report viewer in ASP.NET that presents to the users their data.
the data for all the users is located in the same table.
for now I created DBDataSet and in the TableAdapter there is this method
GetData(@idNumber, @userNumber)
in code behind of the screen that I want to show the report viewer I wrote:
FlightsDBDataSetTableAdapters.ReservationsTableAdapter ReservationsTableAdapter;
ReservationsTableAdapter = new FlightsDBDataSetTableAdapters.ReservationsTableAdapter();
FlightsDBDataSet.ReservationsDataTable newReservationTable;
newReservationTable = ReservationsTableAdapter.GetData(userId, userName);
ObjectDataSource1.SelectParameters.Add("userName", userName);
ObjectDataSource1.SelectParameters.Add("idNumber", userId);
when I run this I get the next error
An error has occurred during report processing. ObjectDataSource
'ObjectDataSource1' could not find a non-generic method
'GetData(idNumber, userName)' that has parameters: userName, idNumber.
SO, my question is where do I need to write the method GetData and how can I generate the report with the right data.
thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个。
1.创建一个方法,如果未在存储过程中传递参数,则返回 db null
2.创建一个方法,该方法将调用存储过程并填充数据集。
现在
拖放 TableAdapter,它会询问您以下详细信息
3.1 连接字符串(选择现有连接字符串或创建新连接字符串)
3.2 选择命令类型(现在选择现有的存储过程,指定您之前创建的存储过程以在报告中显示详细信息
3.3 选择生成方法(选中填充数据表和返回数据表
3.4 单击“下一步”并提交(现在您的数据集将真正在报告中使用)
Try this out.
1.Create a method which will return db null if parameter is not passed in the stored procedure
2.Create a method which will called the stored procedure and fill the dataset.
}
Now you add the dataset let us say 'DataSet1.xsd'
Drag and Drop the TableAdapter and it will ask you the following details
3.1 Connection String (Either Select the existing connection string or create new connection string)
3.2 Choose Command Type (Now select the existing stored Procedure, specify the stored procedure with you have create earlier to display details in the report
3.3 Choose Methods to Generate (check both Fill a Datatable and Return a datatable
3.4 Click on Next and Submit ( Now your dataset is really to use in the report)