This is a migrated thread and some comments may be shown as answers.

Convert sqldatasource to dataTable issues

5 Answers 313 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Fadhli
Top achievements
Rank 1
Fadhli asked on 08 Dec 2011, 03:53 AM
I'm trying to convert sqldatasource to dataTable but I recieved an error.

Here is the error:
'Telerik.Reporting.SqlDataSource' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'Telerik.Reporting.SqlDataSource' could be found (are you missing a using directive or an assembly reference?)


DataSourceSelectArguments args = new DataSourceSelectArguments();
DataView view = (DataView)sqlDataSource1.Select(args);
DataTable table = view.ToTable();

Which namespace should I use and which assembly should I add? Or maybe its not supported?

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 12 Dec 2011, 05:18 PM
Hello Fadhli,

We would appreciate if you provide more information on your scenario - what is your data, what is your report setup, what are you trying to accomplish and where is this code invoked etc.

Regards,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
sulejman Vezi
Top achievements
Rank 1
answered on 09 Jan 2014, 11:10 AM
Hi.

I'm also interested in how to do this.

            DataView dv = new DataView();
            DataTable dt = new DataTable();
            dv = SQLDataSource1.Select(DataSourceSelectArguments.Empty);
            dt = dv.ToTable();


Best
Suli
0
Peter
Telerik team
answered on 10 Jan 2014, 02:31 PM
Hi Suli,

Telerik Reporting SqlDataSource component is a declarative datasource component that is used internally by the reporting engine. It can't be used to fill DataTable or DataView with data. Instead to fill your DataTable our recommendation is to use the standard .NET approach with SqlDataAdapter. For an example check out the Populate DataTable with records from database? stackoverflow article.

Regards,
Peter
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Rahul
Top achievements
Rank 1
answered on 10 Aug 2016, 11:19 AM
Hi All,
I am facing same issue to sqldatasource to DataTable issues. I need this solution to fix below scenario.

In my report I am calling stored procedure using sqldatasource1.  Let’s say Stored procedure is returning data as below.

Column1      Column2        Column3      Column4
RowData     RowData        RowData      RowData
RowData     RowData        RowData      RowData

And I am assigning those data to Report using
       this.DataSource = sqldatasource1

The actual issue is When I export to .csv, It’s returning all the data which SP is returning. I want to remove some column based on condition before I assign to this.dataSource. In front end I am hiding unwanted column but while exporting to .csv it is exporting all the column.
Using DataTable I can Perform this operation like DT.Column.remove(“Column1”). But I same fix is not working with sqldatasource that I can understand but I have below question.
1 ) Is there any other way to control Data to export in .csv file(remove column from sqldatasource ). Without modify in Stored procedure.?
2 ) If no, Then How to perform above operation using sqldatasource.?

Is there anyone having this issue?
Please suggest fix this issue.

Many Thanks,
Rahul
0
Stef
Telerik team
answered on 12 Aug 2016, 09:52 AM
Hi Rahul,

The CSV rendering mechanism exports the report layout with data, means how data is visualized by the report - Design Considerations for CSV Rendering.

If you want to export only data in CSV format, please consider retrieving data in code and exporting in a text file without going through a report e.g. Export Datatable to CSV Using Extension Method (external resource).


I hope this helps.

Regards,
Stef
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Fadhli
Top achievements
Rank 1
Answers by
Steve
Telerik team
sulejman Vezi
Top achievements
Rank 1
Peter
Telerik team
Rahul
Top achievements
Rank 1
Stef
Telerik team
Share this question
or