c# - Crystal report viewer triggers invalid cast exception error -
i using crystal reports ver 14 visual studio 2010/12. continue have problem crystal reports view triggers following: system.invalidcastexception error. when trying set viewer report source.
-running windows os7 latest updates -report has data -report prints directly printer fine
////////////////// create report document////////////////////////////// reportdocument crreport = new reportdocument(); // load .rpt file; statement need changed reference application.startuppath crreport.load(@"c:\cpms.net.sql\cpms.net\crpprojectlist.rpt"); // set report title1, title2, title3 here // txttitle1 // txttitle2 // txttitle3 // set report datasource ds.tables[2]; tables[2] = tbl01_general crreport.setdatasource(ds); // set viewer control , preview report this.axcrystalactivexreportviewer1.begininit(); this.axcrystalactivexreportviewer1.reportsource = crreport; //this line causing problem this.axcrystalactivexreportviewer1.refresh();
code requested commenter:
try { ///////////////////// create ado.net dataset connect report object ///////////////// // initialize connection object, connection string, , sql string sqlconnection cnn; string connectionstring = null; string sql = null; // set connection string server , database , sql string connectionstring = @"data source=vteglasi-think\mssqlexp12;initial catalog=cpms_sql;integrated security=true"; cnn = new sqlconnection(connectionstring); // sql = "select pin, route, worktype, proj_cat, respagency, cont_cost, let_date tbl01_general worktype = '3r'"; // test sql sql = "select [tbl01_general].pin, [tbl01_general].route, [tbl01_general].worktype, [tbl01_general].proj_cat, [tbl01_general].respagency, [tbl01_general].cont_cost, [tbl01_general].let_date, [tbl01_selected].selected tbl01_general, tbl01_selected [tbl01_selected].selected = 1"; // test sql // set sqldataadapter craete data set ds, become data source crreport object sqldataadapter adaptercpms_net = new sqldataadapter(sql,cnn);
Comments
Post a Comment