RDLC Report-custom Dataset

Source: Internet
Author: User
 // Connection string
String connstr = "Data Source =.; initial catalog = wwalmdb; user id = sa; Password = sqlsql ";

// Create a connection
Sqlconnection connection = new sqlconnection (connstr );

// Query command
Sqlcommand command = new sqlcommand (textboxsql. Text, connection );

// Adapter
Sqldataadapter adapter = new sqldataadapter (command );

// Dataset
Dataset DS = new dataset ();

// Query and fill
Try
{
Connection. open ();
Adapter. Fill (DS );
}
Catch (exception ex)
{
MessageBox. Show (ex. Message );
}
Finally
{
Connection. Close ();
Command. Dispose ();
Connection. Dispose ();
}

// Specify the rdlc report
This. reportviewer1.localreport. reportembeddedresource = "formreport. eventreport. rdlc ";

// Clear the previous reportviewer Data Source
This. reportviewer1.localreport. CES. Clear ();

// Create a data source
Reportdatasource rs = new reportdatasource ();
Rs. Name = "eventhistory"; // "eventhistory" is the name of the dataset under the tablib attribute of the rdlc report.
Rs. value = Ds. Tables [0];

// Add a data source
This. reportviewer1.localreport. CES. Add (RS );

// Display data
This. reportviewer1.refreshreport ();

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.