高分请教关于Reporting Service的问题
在开发基于Reporting Service的报表时,我是通过用程序来动态生成rdl文件,代码如下:
//用XmlTextWriter创建一个RDL文件
//打开一个新写入RDL文件
FileStream stream;
stream = File.OpenWrite(FileName);
XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8);
// 根据字节点设置缩进
writer.Formatting = Formatting.Indented;
// 报表元素
writer.WriteProcessingInstruction( "xml ", "version=\ "1.0\ " encoding=\ "utf-8\ " ");
writer.WriteStartElement( "Report ");
writer.WriteAttributeString( "xmlns ", null, "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition ");
writer.WriteElementString( "Width ", "6in ");
// 数据源元素
writer.WriteStartElement( "DataSources ");
writer.WriteStartElement( "DataSource ");
writer.WriteAttributeString( "Name ", null, "DataSource1 ");
writer.WriteStartElement( "ConnectionProperties ");
writer.WriteElementString( "DataProvider ", "SQL ");
writer.WriteElementString( "ConnectString ", m_connectString);
writer.WriteElementString( "IntegratedSecurity ", "false ");
//writer.WriteElementString( "UserName ", "sa ");
//writer.WriteElementString( "PassWord ", "1 ");
writer.WriteEndElement(); // ConnectionProperties
writer.WriteEndElement(); // DataSource
writer.WriteEndElement(); // DataSources