首先添加web引用
http://server/reportserver/reportservice.asmx
ReportingService rService = new ReportingService();//创建报表服务实例
rService.Credentials = System.Net.CredentialCache.DefaultCredentials;//默认系统凭据
CatalogItem[] catalogItems;
catalogItems = rService.ListChildren("/", true);//对根路径检索
foreach(CatalogItem item in catalogItems)
{
if(item.Type ==ItemTypeEnum.Folder)
{
//遍历报表文件夹
}
}
foreach(CatalogItem item in catalogItems)
{
if(item.Type ==ItemTypeEnum.Report)
{
//遍历报表
}
}
//搜索报表
ReportService.SearchCondition[] condition=new SearchCondition[1];
condition[0]=new SearchCondition();
condition[0].Name ="Name";
condition[0].Value =this.TextBox1.Text ;
catalogItems=rs.FindItems ("/",WebReportSample.ReportService .BooleanOperatorEnum .And ,condition);
//发布报表
byte[] reportData;
System.IO .FileStream fs=System.IO .File.OpenRead ("c:\\Report1.rdl");
reportData=new byte [fs.Length ];
fs.Read (reportData,0,fs.Length );
rs.CreateReport ("New Report","/",false,reportData,null);
//删除报表
rs.DeleteItem ("报表名称");
http://server/reportserver/reportservice.asmx
ReportingService rService = new ReportingService();//创建报表服务实例
rService.Credentials = System.Net.CredentialCache.DefaultCredentials;//默认系统凭据
CatalogItem[] catalogItems;
catalogItems = rService.ListChildren("/", true);//对根路径检索
foreach(CatalogItem item in catalogItems)
{
if(item.Type ==ItemTypeEnum.Folder)
{
//遍历报表文件夹
}
}
foreach(CatalogItem item in catalogItems)
{
if(item.Type ==ItemTypeEnum.Report)
{
//遍历报表
}
}
//搜索报表
ReportService.SearchCondition[] condition=new SearchCondition[1];
condition[0]=new SearchCondition();
condition[0].Name ="Name";
condition[0].Value =this.TextBox1.Text ;
catalogItems=rs.FindItems ("/",WebReportSample.ReportService .BooleanOperatorEnum .And ,condition);
//发布报表
byte[] reportData;
System.IO .FileStream fs=System.IO .File.OpenRead ("c:\\Report1.rdl");
reportData=new byte [fs.Length ];
fs.Read (reportData,0,fs.Length );
rs.CreateReport ("New Report","/",false,reportData,null);
//删除报表
rs.DeleteItem ("报表名称");