How to use DataSet and Storedprocedure as FastReport DataSource in VS2008

edited 7:09AM in FastReport .NET
1.I'v generate a DataSet in VS2008 ,and how to use it as FastReport's Datasource in report designer?
2.I droped sqldatasource and webreport component on to default.aspx,and set selectcommand as 'text' and sqlquery retrievedata '33032602001','01/01/2008','12/31/2008','voucher',then set webreport control's datasource as sqldatasource.
but occured an error "error connection or selectcommand syntax error" when I using Intelligence tool to design report

A newbie need help

Comments

  • edited 7:09AM
    Hello,

    1) see programmer's manual, "Working with Windows.Forms/Using the Report component in Visual Studio" chapter (if you work with Windows Forms project). If you want to register a DataSet in ASP.NET project, read the "Working with ASP.NET/Registering data" chapter.
    2) it's not correct use of SqlDataSource, you have to specify the connection string.
  • edited 7:09AM

    1.I'v read proammer's manual.and registerdata(dataset),but still I dont know how to design report in designer that which datasource is dataset.I'm working with ASP.NET.
    2.I'v specified the connectionstring to SqlDataSource, and test correctly when binding it to GridView.
  • edited 7:09AM
    One possible solution is to run a designer at run-time to create a report. To do this:
    - place Button on your aspx page;
    - create the following event handler for it:
            protected void Button1_Click(object sender, EventArgs e)
            {
              Thread th = new Thread(DesignReport);
              th.SetApartmentState(ApartmentState.STA);
              th.Start();
            }
    
            private void DesignReport()
            {
              Report report = new Report();
              // create the DataSet instance
              crosstestDataSet ds = new crosstestDataSet();
              // register it in a report
              report.RegisterData(ds);
              // run the designer
              report.Design();
              // dispose a report
              report.Dispose();
            }
    

    Note that this will work only on your local machine. Run your project, press the Button - you will be able to design a report and save it to a file, then use this file in your ASP.NET project. Once you have designed a report, remove this Button and all associated code (or hide it).

    To use the report you have designed:
    - add report file to your project via Solution Explorer. App_Data folder is good for this;
    - put WebReport component on your aspx page;
    - go Properties window and invoke the "ReportFile" property editor;
    - select App_Data\report.frx file.

    To run a report, you need to register the DataSet. Use the WebReport.StartReport event handler:
            protected void WebReport1_StartReport(object sender, EventArgs e)
            {
              Report report = WebReport1.Report;
              crosstestDataSet ds = new crosstestDataSet();
              report.RegisterData(ds);
            }
    
  • edited 7:09AM
    This code works not correct. Anothers error occured, perhaps there's some wrongs in anothers parts of my code.Can I work it in design time that using Dataset but not implement it by code which is inconvenient.

    Secondary how to use SqlDataSource with Storedprocedure,which is success in using a table as a datasource.

    Thanks for your help firstly
  • edited July 2009
    This solution works well for me, I've checked it on a simple project before posting here.

    Another way is to use ObjectDataSource, bind it to your DataSet and then register in a report. This can be done in a visual manner.

    I've tested stored proc as well - it works fine (I have a test database with MiProc2 proc with one string parameter).
  • edited 7:09AM
    God bless.I found solution from topic in this forum.
    But I still dont know how to use DataSet as DataSource in VS.

    Thanks AlexTZ
  • edited 7:09AM
    Please read my previous post.
    wrote:
    Another way is to use ObjectDataSource, bind it to your DataSet and then register in a report. This can be done in a visual manner.
  • edited August 2009
    That is,Put Register(Dataset) to StartPage event handler? Will this event fired in design time? I think not, startpage event isn't fired then I can't register a DataSeta in design time. Maybe I am not understanding your meaning clearly.

    Any additional question:

    1.I'v set column's size to 'cangrow'.Still, there are many rows' height didnt grow when one column's text is very long and text being clipped.But, some rows work well.It looks like have no regulation.And when change font,rows' height changed with also no regulation.
    2.My report have two Databand and one Datahead, on which I put a total column,that on the head of second Databand. But the Datahead content didn't show on the first page when it on first page whereas other pages work well when it on other pages at run time.
    3.Does FastReport .net demo version have expiration or client connections limitation?

    Best Regards
  • edited 7:09AM
    No, it can be done visually, without writing any code. Once you create a ObjectDataSource component, you can use it in a report, as described in the programmer's manual, "Working with ASP.NET/Using the WebReport component" chapter.

    1,2 - I can't say what's wrong, I need a demo report that demonstrates this behavior.
    3 - no it does not.
  • edited 7:09AM
    I did as programmer's manual indicate.But in designer,has no correct tables and columns show in Datasource, just objectdatasource1, tree list 'Databinding: col0','Databinding: col1','Databinding: col2'
  • edited 7:09AM
    That means your ObjectDataSource is not properly connected to data. You can connect ObjectDataSource to only one table in a DataSet. In this case, you will see all columns of this table. Do a simple task: configure the ObjectDataSource and connect it to standard GridView. If it's ok, you will able to use it in FastReport as well.
  • edited September 2009
    Hi Alex,

    I tried this as you mention in post#4. But its displaying the data directly from the test.frx file, instead of Dataset.

    Please help.


    Irfan
  • edited 7:09AM
    Hello,

    The report does not contain any data. It contains datasource schema only. So I don't understand this:
    wrote:
    But its displaying the data directly from the test.frx file, instead of Dataset.
  • edited 7:09AM
    AlexTZ wrote: »
    Hello,

    The report does not contain any data. It contains datasource schema only. So I don't understand this:
    AlexTZ wrote: »
    But its displaying the data directly from the test.frx file, instead of Dataset.

    Hey Hurray !! Right, datasource schema... Thanx Alex. Its working now. >
  • mohanarajmohanaraj 600001
    edited 7:09AM
    Dear Alex,

    i read the post #4 you mentioned as the "run this code in the local machine" that means run this as windows application? or web application.

    When select the design report in the webreport component that placed in the aspx page it display the connection wizard window to create new connection in that only display the connection type as MS Access Connection, XMl Databse, OLEDB Connection, MS SQL Connection in that what i choose? to load my dataset. As you mention, i did report.register to register my dataset before that how can i design the report with the fields from the stored procedure. Please guide me i'm in urgent to finish this task.
  • edited 7:09AM
    Go to the "Data|Choose Report Data..." menu. Did you see tables of your dataset?
  • mohanarajmohanaraj 600001
    edited 7:09AM
    AlexTZ wrote: »
    Go to the "Data|Choose Report Data..." menu. Did you see tables of your dataset?


    Hai Alex,

    Thanks, I got it. Do you suggest how to do summary report.
  • edited 7:09AM
    Hello,

    Please read the user's manual, it has a chapter "Report creation" which covers all report types.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.