all groups > sql server reporting services > april 2005 >
You're in the

sql server reporting services

group:

IDBCommandAnalysis



IDBCommandAnalysis Dan
4/11/2005 10:03:02 PM
sql server reporting services: Has anyone implemented this interface?

If so would you be willing to share your code?

RE: IDBCommandAnalysis Dan
4/11/2005 11:10:01 PM
Sorry, the group took so long to refresh i thought it wasn't working (and i
submitted it 3 times grrrrr)

[quoted text, click to view]
RE: IDBCommandAnalysis Herman K
4/13/2005 4:03:03 PM
An explanation may be in order as well.
ParametersRequiredForCommandExecution is a ReportingDBDataParameterCollection
containing all those parameters wither parsed out of a query string or from a
Stored Procedure.

You can see in the code below that I parse CommandText (for CommandType.Text
commands) and call a SPROC I wrote to return the parameters required by a
given stored procedure.

internal ReportingDBDataParameterCollection
ParametersRequiredForCommandExecution
{
get
{
if (parametersRequiredForCommandExecution == null)
{
parametersRequiredForCommandExecution = new
ReportingDBDataParameterCollection();

if (this.commandType == CommandType.Text)
{
//Process for CommandType.Text
int indexOf = 0;
int startIndex = 0;
indexOf = commandText.IndexOf("@", startIndex);
while (indexOf != -1)
{
string s = commandText.Substring(indexOf);
string[] tokens = s.Split(new char[] {' '});
parametersRequiredForCommandExecution.Add(new
ReportingDBDataParameter(tokens[0], null));

startIndex = indexOf + 1;
indexOf = commandText.IndexOf("@", startIndex);
}

}
else
{
//Process for CommandType.StoredProcedure
if (commandText.Trim() != string.Empty)
{

//Extract the stored procedure name from commandText (assume first
token is SPROC name)
string[] tokens = commandText.Split(new char[] {' '});
string storedProcedureName = tokens[0];

//Establish a connection to a 'template' database (any instance of a
target DB that we can always
//be sure is present) to try to get the SPROC's parameters from.
Note we cannot go to the specific
//target at this point becuase we have not had an opportunity to
gather any runtime information (which,
//through the MemberID would tell us the specific database to go to).
TemplateReportingDB templateReportingDB = new TemplateReportingDB();
SqlConnection connection = new
SqlConnection(templateReportingDB.ConnectionString);
connection.Open();

//Set up a command object
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = "spRPT_StoredProcedureParameters";
command.Parameters.Add("@StoredProcedureName", storedProcedureName);

//Go get the paramters using the SPROC specified above
SqlDataReader reader = command.ExecuteReader();

//See what we got back
int targetColumn;
if (reader.HasRows)
{
targetColumn = reader.GetOrdinal("PARAMETER_NAME");
}
else
{
throw new Exception("Stored procedure " + storedProcedureName + "
was not found in the target database.");
}

while (reader.Read())
{
parametersRequiredForCommandExecution.Add(new
ReportingDBDataParameter(reader.GetString(targetColumn), null));
}

connection.Close();
}
}
}

return parametersRequiredForCommandExecution;
}
}


[quoted text, click to view]
RE: IDBCommandAnalysis Dan
4/14/2005 3:01:03 AM
is there any way to directly access the parameters setup in the designer?

[quoted text, click to view]
RE: IDBCommandAnalysis Herman K
4/14/2005 2:50:05 PM
You'll have to be more specific. The parameter values the report developer
specifies after pressing ! (run)? The parameters that accompany command text
(such as SELECT * FROM tbl WHERE tbl.fld=@parm)? The parameters required by
a stored procedure in the command text? The parameters specifed for the
report in the Report Parameters dialog?

What is it you are seeking?

[quoted text, click to view]
RE: IDBCommandAnalysis Dan
4/14/2005 6:49:02 PM
The parameters specifed for the report in the Report Parameters dialog
or
The parameters specified in the paramters tab of a dataset

either one will get me what i need

[quoted text, click to view]
AddThis Social Bookmark Button