asp.net中利用vsreport打印报表?
为什么显示字段名,而不是数据库表中的数据,而且记录数还跟表的记录数一样。用vsreport的设计器,在预览时也只显示字段名(记录的数据全部显示为字段名)。高手帮个忙吗?
public static void GetPrintVp(string strSql,string XmlFilePath,string VpFilePath,string ReportName)
{
VSReport8Lib.VSReport vsr= new VSReport8Lib.VSReport();
vsr.Load(XmlFilePath,ReportName);
//vsr.DataSource.ConnectionString = "provider=SQLOLEDB.1;server=127.0.0.1;uid=sa;password=manager;database=water ";
vsr.DataSource.RecordSource = strSql;
vsr.RenderToFile(VpFilePath,VSReport8Lib.FileFormatSettings.vsrVSPrinter);
}
private void Button2_Click(object sender, System.EventArgs e)
{
GetPrintVp( "select * from tb_材料名称表 ",Server.MapPath( ".\\xml\\tt.xml "),Server.MapPath( "t.vp "), "tb_材料名称表 ");
Response .Write( " <object classid= 'clsid:C0489F4D-67C4-4069-9E3E-95245F084E3F ' codeBase= 'ocxPack/vsrpt8.ocx#version=8,0,0,0 ' id= 'VSReport1 '> </object> ");
Response .Write( " <object classid= 'clsid:819F123A-B24A-4EB8-BED1-B5DFC5CB5194 ' id= 'VSPrinter1 ' codeBase= 'ocxPack/vsprint8.ocx#version=8,0,0,0 ' width= '700 ' height= '500 '> ");
Response .Write( " <param name= 'URL ' value= ' "+ Server.MapPath( "t.vp ") + " '> ");
}
------解决方案--------------------select * from tb_材料名称表
用查询分析器,看看有没有数据