資源簡介
這是以個c#做的報表例子,
//打開連接
conReport.Open();
//準備連接對象以把獲取的數據放入數據集
cmdReport.CommandType = CommandType.Text;
cmdReport.Connection = conReport;
cmdReport.CommandText = "Select TOP 5 * FROM Products Order By ProductName";
//從命令對象中讀取數據
drReport = cmdReport.ExecuteReader();
//有了ADO.NET,可把讀取來的數據直接加載到數據集中
dsReport.Tables[0].Load(drReport);
//關閉讀取及連接
drReport.Close();
conReport.Close();
//為查看器提供本地報表數據
this.reportViewer1.LocalReport.ReportEmbeddedResource =
"報表問題.rptProductList.rdlc";
//準備報表數據源
ReportDataSource rds = new ReportDataSource();
rds.Name = "dsProduct_dtProductList";
rds.Value = dsReport.Tables[0];
this.reportViewer1.LocalReport.DataSources.Add(rds);
//加載報表查看器
this.reportViewer1.RefreshReport();
}
catch (Exception ex)
{
//顯示錯誤信息
MessageBox.Show(ex.Message);
}
finally
{
//檢查連接是否仍然打開,如果是,關閉它。
if (conReport.State == ConnectionState.Open)
{
conReport.Close();
}

代碼片段和文件信息
//------------------------------------------------------------------------------
//?
//?????此代碼由工具生成。
//?????運行庫版本:2.0.50727.42
//
//?????對此文件的更改可能會導致不正確的行為,并且如果
//?????重新生成代碼,這些更改將會丟失。
//?
//------------------------------------------------------------------------------
#pragma?warning?disable?1591
namespace?報表問題?{
????using?System;
????
????
????[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.Data.Design.TypedDataSetGenerator“?“2.0.0.0“)]
????[Serializable()]
????[System.ComponentModel.DesignerCategoryAttribute(“code“)]
????[System.ComponentModel.ToolboxItem(true)]
????[System.xml.Serialization.xmlSchemaProviderAttribute(“GetTypedDataSetSchema“)]
????[System.xml.Serialization.xmlRootAttribute(“dsProduct“)]
????[System.ComponentModel.Design.HelpKeywordAttribute(“vs.data.DataSet“)]
????public?partial?class?dsProduct?:?System.Data.DataSet?{
????????
????????private?dtProductListDataTable?tabledtProductList;
????????
????????private?System.Data.SchemaSerializationMode?_schemaSerializationMode?=?System.Data.SchemaSerializationMode.IncludeSchema;
????????
????????[System.Diagnostics.DebuggerNonUserCodeAttribute()]
????????public?dsProduct()?{
????????????this.BeginInit();
????????????this.InitClass();
????????????System.ComponentModel.CollectionchangeEventHandler?schemaChangedHandler?=?new?System.ComponentModel.CollectionchangeEventHandler(this.SchemaChanged);
????????????base.Tables.Collectionchanged?+=?schemaChangedHandler;
????????????base.Relations.Collectionchanged?+=?schemaChangedHandler;
????????????this.EndInit();
????????}
????????
????????[System.Diagnostics.DebuggerNonUserCodeAttribute()]
????????protected?dsProduct(System.Runtime.Serialization.SerializationInfo?info?System.Runtime.Serialization.StreamingContext?context)?:?
????????????????base(info?context?false)?{
????????????if?((this.IsBinarySerialized(info?context)?==?true))?{
????????????????this.InitVars(false);
????????????????System.ComponentModel.CollectionchangeEventHandler?schemaChangedHandler1?=?new?System.ComponentModel.CollectionchangeEventHandler(this.SchemaChanged);
????????????????this.Tables.Collectionchanged?+=?schemaChangedHandler1;
????????????????this.Relations.Collectionchanged?+=?schemaChangedHandler1;
????????????????return;
????????????}
????????????string?strSchema?=?((string)(info.GetValue(“xmlSchema“?typeof(string))));
????????????if?((this.DetermineSchemaSerializationMode(info?context)?==?System.Data.SchemaSerializationMode.IncludeSchema))?{
????????????????System.Data.DataSet?ds?=?new?System.Data.DataSet();
????????????????ds.ReadxmlSchema(new?System.xml.xmlTextReader(new?System.IO.StringReader(strSchema)));
????????????????if?((ds.Tables[“dtProductList“]?!=?null))?{
????????????????????base.Tables.Add(new?dtProductListDataTable(ds.Tables[“dtProductList“]));
????????????????}
????????????????this.DataSetName?=?ds.DataSetName;
????????????????this.Prefix?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????925??2010-01-29?16:23??報表問題\報表問題.sln
????..A..H.?????19968??2010-10-13?21:15??報表問題\報表問題.suo
?????文件??????28135??2010-01-29?19:02??報表問題\報表問題\dsProduct.Designer.cs
?????文件????????381??2010-01-29?19:02??報表問題\報表問題\dsProduct.xsc
?????文件???????3200??2010-01-29?19:02??報表問題\報表問題\dsProduct.xsd
?????文件????????855??2010-01-29?19:02??報表問題\報表問題\dsProduct.xss
?????文件???????3158??2010-01-29?20:14??報表問題\報表問題\Form1.cs
?????文件???????2163??2010-01-29?20:14??報表問題\報表問題\Form1.Designer.cs
?????文件???????5814??2010-01-29?20:14??報表問題\報表問題\Form1.resx
?????文件????????471??2010-01-29?16:23??報表問題\報表問題\Program.cs
?????文件??????16745??2010-01-30?10:55??報表問題\報表問題\rptProductList.rdlc
?????文件???????5946??2010-01-29?19:18??報表問題\報表問題\報表問題.csproj
?????文件??????49152??2010-01-30?10:55??報表問題\報表問題\bin\Debug\報表問題.exe
?????文件??????54784??2010-01-30?10:55??報表問題\報表問題\bin\Debug\報表問題.pdb
?????文件???????5632??2005-11-11?22:25??報表問題\報表問題\bin\Debug\報表問題.vshost.exe
?????目錄??????????0??2010-09-03?20:40??報表問題\報表問題\bin\Debug
?????目錄??????????0??2010-09-03?20:40??報表問題\報表問題\bin
?????文件????????406??2010-10-13?21:13??報表問題\報表問題\obj\報表問題.csproj.FileList.txt
?????文件????????534??2010-01-30?10:55??報表問題\報表問題\obj\Debug\RdlCompile.cache
?????文件??????????0??2010-01-30?10:55??報表問題\報表問題\obj\Debug\RdlCompile.compiled
?????文件??????24670??2010-01-29?16:25??報表問題\報表問題\obj\Debug\ResolveAssemblyReference.cache
?????文件????????842??2010-01-29?20:14??報表問題\報表問題\obj\Debug\報表問題.csproj.GenerateResource.Cache
?????文件??????49152??2010-01-30?10:55??報表問題\報表問題\obj\Debug\報表問題.exe
?????文件????????180??2010-01-29?20:14??報表問題\報表問題\obj\Debug\報表問題.Form1.resources
?????文件??????54784??2010-01-30?10:55??報表問題\報表問題\obj\Debug\報表問題.pdb
?????文件????????180??2010-01-29?16:25??報表問題\報表問題\obj\Debug\報表問題.Properties.Resources.resources
?????文件??????16745??2010-01-30?10:55??報表問題\報表問題\obj\Debug\報表問題.rptProductList.rdlc
?????文件??????16896??2010-01-29?19:02??報表問題\報表問題\obj\Debug\TempPE\dsProduct.Designer.cs.dll
?????目錄??????????0??2010-09-03?20:40??報表問題\報表問題\obj\Debug\TempPE
?????目錄??????????0??2010-09-03?20:40??報表問題\報表問題\obj\Debug
............此處省略12個文件信息
評論
共有 條評論