Create report from non-query and non-stored proc dataset

  • Hi,

    is it possible to create a report were the dataset is populated by code? ie. i don't want a query and i don't want to use a stored procedure.

    I tried writing my own custom code and calling it from the query string, but it throws an error.

    Carolyn

  • What error do you get?

    We have few that the dataset's Command Type is set to "text", and in there is any regular script.

    Be careful to return only one recordset (only one select statement), and enable "nocount" just in case.

  • Hi, thanks for your reply. This is what i'm doing:

    I have a class file called CustomCode (which i have used for other custom functions in reports, so i know i've deployed it right etc), and in it is a method called GetReportData. it simply returns a datatable with one row of data in it:

    public static DataTable GetDataForReport()

    {

    DataTable dt = new DataTable();

    dt.Columns.Add("FirstName");

    dt.Columns.Add("LastName");

    dt.Columns.Add("Address");

    dt.Columns.Add("City");

    dt.Columns.Add("State");

    dt.Columns.Add("PhoneNumber");

    DataRow row = dt.NewRow();

    row["FirstName"] = "Carolyn";

    row["LastName"] = "Farley";

    row["Address"] = "10 My Street";

    row["City"] = "Newcastle";

    row["State"] = "NSW";

    row["PhoneNumber"] = "123456";

    dt.Rows.Add(row);

    return dt;

    }

    I have a blank report, in which i have created a dataset. The Command Type i set to "text" and the Query String has the following line of code:

    =CustomCode.CustomCode.GetDataForReport()

    when i try and preview the report i get the error:

    "An error occurred during local report processing.

    An error has occurred during report processing.

    Cannot set the command text for data set 'DataSet1'.

    Error during processing of the CommandText expression of dataset 'DataSet1'."

    Thanks for your help,

    Carolyn

  • I'm sorry, I meant any T-SQL script. I have never used VB scripts.

    But try returning a dataset instead of a table.

     

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply