Page 1 of 1

Save data in the Database

Posted: Fri Sep 10, 2010 1:43 am
by jjc
Hi Stimulsoft,
in my report i must to add a new task as i exaplin you know,
in the Database (SqlServer) that i use to retrieve data to compile the report i create a Table (ReportCompiled) to save each time the data of report created, with these field :

- ReportId (int)
- ReportName (string)
- Country (string)
- Language (string)
- Operator (string)
- Recharge (decimal)
- DateCreated (datetime)
- DateModified(datetime)
- UserModified (string)
- Report (byte) -----> to save the report in .MDC and reuse when need to change some feature.

My purpose of this Table is to save the data for each report created (i wish perform it just clicking a Button to save data in database) and so i ask you if it is possible perform this task (i did not see examples about that) and if there are some example where i can take some idea.

Thanks for your attention.

Have a good day.

Cheers

Save data in the Database

Posted: Fri Sep 10, 2010 7:32 am
by Alex K.
Hello,

You can create the procedure that will add a record to the table in your base

Code: Select all

CREATE PROCEDURE [dbo].[InsertIntoTableValueFromReport]
	(@ReportID int, @ReportName varchar(50), @Country varchar(50))
AS
BEGIN
   INSERT INTO TableReport(ReportID, ReportName,Country) VALUES(@ReportID,@ReportName,@Country)
END
In your report in dictionary add Stored Procedure with parameters @ReportID,@ReportName,@Country.

Code: Select all

exec InsertIntoTableValueFromReport @ReportID,@ReportName,@Country
Then, when pressing the button, pass parameters to this procedure in the report and run for execution.

Thank you.

Save data in the Database

Posted: Fri Sep 10, 2010 11:53 pm
by jjc
Hi Aleksey ,
your snippet work good :blush: , i can save the data in my Table but just one step i get stuck ;
in my table i create a field : Report (Varbinary) -----> to save the report in .MDC and reuse when need to change some feature, and i am trying the way hot to save the Report in the database .
Should i use a snippet like this one:

Code: Select all

using (Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport())
{

byte[] reportByte = report.SaveToByteArray(); 
reportByte = report.SaveToByteArray(); 
and after pass this value to the parameter and save in the Database?

Thanks for you attention.

Have a good day.

Cheers

Save data in the Database

Posted: Mon Sep 13, 2010 8:11 am
by Alex K.
Hello,

In this case, you can save the report in the EndRender event: SaveDocumentToByteArray()
create a new SQLConnection, create a new SQLCommand, send the saved report to the parameter and execute.

Thank you.

Save data in the Database

Posted: Thu Sep 16, 2010 10:04 pm
by jjc
Hi Aleksey,
i tried to follow your way but not luck ,so i ask you if there is a document about this task so i can underdtand better how to work out it.

Thanks for your attention.

Have a good day.

Cheers

Save data in the Database

Posted: Mon Sep 20, 2010 5:55 am
by Alex K.
Hello,
jjc wrote:i tried to follow your way but not luck ,so i ask you if there is a document about this task so i can underdtand better how to work out it.
Unfortunately, there is such a documentation on this issue because we think that this action is a bit not correct. The report designer must only show data without making any changes in the database, any changes in the database should be made in your application, but not in the report.

Thank you.