Page 1 of 1

Save a report to SQL varchar(Max), but always Load a Empty Report

Posted: Thu Sep 24, 2009 10:35 pm
by danic
Hi, this is my first time to use this product.

my application can trace the save event successfully,

but when I load the report again,

it shows empty report!!!

this is my code:




protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{

StiWebDesigner1.Report = GetReport(Request["ReportNo"]);
StiWebDesigner1.Report.ReportName = Request["ReportNo"];
StiWebDesigner1.Design();
}
}

protected void StiWebDesigner1_SaveReport(object sender, Stimulsoft.Report.Web.StiWebDesigner.StiSaveReportEventArgs e)
{
SqlConnection conn = new SqlConnection();
string connstring = ConfigurationManager.ConnectionStrings["ConnectionString2"].ConnectionString;
conn = new SqlConnection(connstring);
conn.Open();

string FileOutPut = "";
StiReport report = e.Report;
FileOutPut = report.SavePackedDocumentToString();

SqlCommand sc = new SqlCommand("Update Report Set ReportFile =@Pointer, ReportEditDate=" + DateTime.Now.ToShortDateString() + " WHERE (ReportNo = '" + report.ReportName + "')", conn);
SqlParameter ptrParm = sc.Parameters.Add("@Pointer", SqlDbType.VarChar);
ptrParm.Value = FileOutPut;

sc.ExecuteNonQuery();
conn.Close();
}

protected StiReport GetReport(String ReportNo)
{
SqlConnection conn = new SqlConnection();
string connstring = ConfigurationManager.ConnectionStrings["ConnectionString2"].ConnectionString;
conn = new SqlConnection(connstring);
conn.Open();

string FileOutPut = "";

SqlCommand sc = new SqlCommand("SELECT ReportFile FROM Report WHERE (ReportNo = '" + ReportNo + "')", conn);

SqlDataReader mr = sc.ExecuteReader();

StiReport report = new StiReport();

if (mr.Read())
{
FileOutPut = mr["ReportFile"].ToString();
}
else
{
return null;
}
mr.Close();
report.LoadPackedDocumentFromString(FileOutPut);

SqlDataAdapter newDataAdapter = new SqlDataAdapter("Select * from myTable", conn);
DataSet newDataSet = new DataSet();

newDataAdapter.Fill(newDataSet);

//
report.RegData("myTable", newDataSet);
report.Dictionary.Connect();
conn.Close();
//report.Compile();
return (report);
}


I use the verson 2009.2,

really need your help!!

Save a report to SQL varchar(Max), but always Load a Empty Report

Posted: Fri Sep 25, 2009 1:27 am
by danic
when I change the code :

report.SavePackedDocumentToString();
LoadPackedDocumentFromString(FileOutPut);


to this one:

report.SaveToString();
SavePackedDocumentFromString(FileOutPut);

the problem all clear!?

Can anyone tell me why??

Save a report to SQL varchar(Max), but always Load a Empty Report

Posted: Fri Sep 25, 2009 2:09 am
by Andrew
Hello,

Please, send us a simple application example for testing to support@stimulsoft.com. It is very hard to find the problem in you code.

Thank you.