RDLCレポート---カスタムデータセット
6323 ワード
//
string
connstr
=
"
Data Source=.;Initial Catalog=WWALMDB;User ID=sa;Password=sqlsql
"
;
//
SqlConnection connection
=
new
SqlConnection(connstr);
//
SqlCommand command
=
new
SqlCommand(textBoxSQL.Text, connection);
//
SqlDataAdapter adapter
=
new
SqlDataAdapter(command);
//
DataSet ds
=
new
DataSet();
//
try
{
connection.Open();
adapter.Fill(ds);
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
connection.Close();
command.Dispose();
connection.Dispose();
}
//
rdlc
this
.reportViewer1.LocalReport.ReportEmbeddedResource
=
"
FormReport.EventReport.rdlc
"
;
//
reportviewer
this
.reportViewer1.LocalReport.DataSources.Clear();
//
ReportDataSource rs
=
new
ReportDataSource();
rs.Name
=
"
EventHistory
"
;
//
"EventHistory" rdlc Tablib
rs.Value
=
ds.Tables[
0
];
//
this
.reportViewer1.LocalReport.DataSources.Add(rs);
//
this
.reportViewer1.RefreshReport();