ReportViewer Report from DataTable

I was wondering if there is a way to create a report for ReportViewer from an SQL query. So, from the SQL query, I get all the data that I need to create a report, and then create a report in the designer?

I am very new to ReportViewer and I am very confused. Now I see that I can populate the DataSet from the wizard, however, as far as I can tell, there is no way to throw the SQL query there and then from it.

Do I want this to be possible, or do I need to use a DataGridView? I really want to use reportviewer because of print / export support. Is there any literature on this?

+3
source share
2 answers

LocalReport Class (reportViewer.LocalReport), SSRS ( ), .

ReportDataSource , DataTable.

RDL.

. xml :

<DataSources>
    <DataSource Name="MyDataSource">
      <ConnectionProperties>
        <ConnectString />
        <DataProvider>SQL</DataProvider>
      </ConnectionProperties>
    </DataSource>
    ...
</DataSources>

<DataSets>
    <DataSet Name="MyDataSet">
      <Query>
        <CommandText>MyDataSet</CommandText>
        <DataSourceName>MyDataSource</DataSourceName>
      </Query>
      <Fields>
        <Field Name="Id">
          <DataField>ID</DataField>
        </Field>
        <Field Name="SomeOtherField">
          <DataField>SOME_OTHER_FIELD</DataField>
        </Field>
      </Fields>
   </DataSet>
</DataSets>
+1

-, , ( SQL Server). ReportViewer.

. , SQL-, .

. , . ( SQL, ..). .

, , , .

+1

Source: https://habr.com/ru/post/1753844/


All Articles