Multiple Calls To ServerReport.SetParameters() With Varying Numbers Of Parameters
Jun 20, 2007
I'm new to programming with the ReportViewer object and this issue has me stumped: it appears if you have some optional parameters in your report, and a way to refresh that report with different parameter values, the report "remembers" parameter values from previous calls to SetParameters() on subsequent renderings of the report. If a parameter is included in a call to ServerReport.SetParameters() on the first rendering, but not included in a subsequent call and the report is re-rendered, the previous value of the parameter (rather than the default value) appears to be used.
Here's a snippet of some test code I wrote within an ASP.NET 2.0 test application:
retVal[paramCount++] = new ReportParameter("Name", txtName.Text);
if (txtAddress.Text != "")
retVal[paramCount++] = new ReportParameter("Address", txtAddress.Text);
if (txtZip.Text != "")
retVal[paramCount++] = new ReportParameter("Zip", txtZip.Text);
return retVal;
}
The test report was written to simply echo back the values of the parameters that are specified. The report definition allows NULL to be specified for the parameters.
The test app was written so if I enter a blank value for Name, Address or Zip, the corresponding parameter does not get created in C# and does not get sent to the report server. If I view the report with all three values (parameters) filled in, I see the parameters echoed back to me in my simple report as expected. If I clear the parameter values the first time the report is rendered, none are sent to the report server and I get no values echoed back in my report, also as expected. I can change the values and click on the View Report button and see the new values for the parameters as expected. However, if I clear any previously-specified parameters and click on View Report, the previously-specified values for the ones that are now cleared are still displayed by the report.
So my question is: once a parameter has been sent to the report, how does one "unsend" it on subsequent refreshes? I know I can create the parameter and set its value to null...but I have a situation here where that can cause errors. It'd be better if I could simply leave out the unspecified parameters and have the report refresh and render as if I were rendering it for the first time.
I have a report that includes two required parameters where the values are defined to be 'from query' and where the set of values displayed/allowed for the second parameter/drop-down are dependent on the selection from the first parameter/drop-down.
While this works fine in Visual Studio and via the ReportManager web interface, when I attempt to use the Windows Forms ReportViewer control and supply the parameter values via the ReportViewer.ServerReport.SetParameters() call the report does not accept the input values and indicates that no value has been supplied for the first parameter even though it was. Note that I am calling SetParameters() in code and not using the viewer control's parameter prompts (because they are ugly and allow for no validation beyond required/not-required).
I have tried a number of work-arounds but it seems that the only option is to change the implementation of the report so that the 'from query' parameters are no longer 'from query' but instead just simple input fields.
This allows the ReportViewer control and associated code to work, but since the input values I need are actually GUID values this is obviously less than ideal for running the report from Visual Studio or the web interface.
Am I missing something or is this some kind of a limitation/bug in the viewer control?
I am trying to query a list in sharepoint using its lists.asmx webservice and in turn its GetListItems call. I currently have the call working using the following code in the Querystring for the report
This seems to work fine except that the list has some empty fields in the first record and for some unbelivable reason they (the empty fields) do not get returned as part of the dataset unless i put a value into them. I then came across a parameter for GetListItems called viewFields which is supposed to . Tehn sample Soap request is shown as follows
As i have a parameter for viewfields setup.... What value do i pass to it ??? My XML is in its infancy but i though something along the lines of the following would do as an input.
Also, maybe i am going the wrong way about this.Is there an easier way of defining the Parameters as part of the Querystring or do Parameters always have to be setup in the parameters tab (My Parameter values are static and will never change).
I've got a performance issue. Here's in global what the sp (Let's call it SP_A) does. Step 1 Call a different SP (Lets call it SP_B) and store the output in a variable Step 2 SP_B runs a select statement that returns 1 value Step 3 SP_A uses this value as a parameter in a select statement. Step 4 The result of the SP_A is the result of the select statement (744 rows (always))
All tables used in SP_A and SP_B are temp tables. Total performance of SP_A is between 0.090 and 0.140 seconds.
The problem is that this SP is called 180 times from outside SQL server. That means that the total processing time is somewhere between 21 and 25 seconds.
When I move the entire processing to within SQL server I gain only 2 seconds. So I lose 2 seconds in connecting to the database 180 times.
Can someone give me some pointers on where to look for performance wins?
I have an old app that I'm trying to recode and improve performance.
From the start it makes three seperate calls to a db, checks to see if the record exists, if it doesn't it adds it, then takes the data from all three and inserts it into a final call.
Here is a quick example of the script
Select * from table1 where id = " & tempVariable If Not RS.EOF Then strTable1 = RS("SomeRec") Else RS.ADDNEW RS("SomeRec") = tempRec1 RS.UPDATE RS.Requery strTable1 = RS("SomeRec") End If RS.CLOSE
Select * from table2 where id =2 If Not RS.EOF Then strTable2 = RS("SomeRec") Else RS.ADDNEW RS("SomeRec") = tempRec2 RS.UPDATE RS.Requery strTable2 = RS("SomeRec") End If RS.CLOSE
Select * from table3 where id =3 If Not RS.EOF Then strTable3 = RS("SomeRec") Else RS.ADDNEW RS("SomeRec") = tempRec3 RS.UPDATE RS.Requery strTable3 = RS("SomeRec") End If RS.CLOSE
I am getting a headache trying to research what to do when you have a large number of parameters to include in a query. For example, if I have a large number of checkboxes for the user to pick criteria for a report and they select several, I'm assuming it would be bad practise to say:
WHERE Field = "a" OR Field = "b" OR Field = "c" OR Field = "d" OR Field = "e" OR.....etc etc etc
Is there a good solution for this, given that the number of parameters may vary dramatically depending on what the user selects to include in a report?!
I'm running SQL Server 2000 with an ASP front end.
Myreportviewer.ServerReport.ReportServerCredentials, and let users access the reports on the report server no matter whether the asp app and report server are on the same server. I set up the username, password and domain for the network credentials, and set it to the reportServerCredentials. but when the app running, throught the reportviewer, the report can be access, but no data can be got from datasource(some parameters comes from queries on datasource, and they are unavaible and greyed). if I don't set the reportservercredentials but use <indentidy impersonate = true> and use the windows authentication(disable the anonymouse access) in the iis, it works well, but it works only when aasp app and reportserver are on the same server.
I have a vb.net application using report services that has a big delay when I set the parameters with which to call the report.
I create a new reporting.reportviewer.
I set the ReportServerCredentials.NetworkCredentials, ReportServerUrl, ProcessingModem, ReportPath and everything is fine.
When I call SetParameters with a very simple parameter set, I get a delay of between 0.5 and 2.5 seconds. That delay is very noticible to the users. Below is an extract of a sql profiler trace to a database showing the start time, end time, event class and data text of the sql. I've marked the area with the delay in red.
I have no idea what is happening at that time, but Is there anything I can do to get rid of that delay?
It seems that it could be the first time the my application has had to interface with reporting services.
I have a report with a column which contains either a string such as "N/A" or a number such as 12. A user exports the report to Excel. In Excel the numbers are formatted as text.
I already tried to set the value as CDbl which returns error for the cells containing a string.
The requirement is to export the column to Excel with the numbers formatted as numbers and the strings such as "N/A' in the same column as string.
Hi, I am trying to build search engin with 11 parameters in 4 different tables in the database. For example: In search.aspx I have 11 textboxes namely nameTextbox, phoneTextbox, nationalityTextbox, ageTextbox etc. And in the result.aspx page I have gridview which post data from the database if the search match. I wrote this stored procedure. P.S please ignore the syntax. @name var(30),
@nationality (30),
@phone int,
etc
as
Select a.UserId, b.UserId, c.UserId FROM Table1 a, Table2 b, Table3 c
WHERE
name LIKE '%' @name '%'
OR nationality LIKE '%' @nationality '%'
OR phone LIKE '%' @phone '%'
etc
But I got an error when I am trying to execute this code because the nulls values so I wrote 1 @name var(30), 2 3 @nationality (30), 4 5 @phone int, 6 7 etc 8 9 as 10 11 12 13 Select a.UserId, b.UserId, c.UserId FROM Table1 a, Table2 b, Table3 c 14 15 WHERE 16 17 name LIKE '%' ISNULL(@name, '') '%' 18 19 OR nationality LIKE '%' ISNULL(@nationality,'') '%' 20 21 OR phone LIKE '%' ISNULL(@phone,'') '%' 22 23 etc 24 25
Also the error still exist. What is the best way to search for multiple parameters in multiple tables ?
Why does M$ Query Analyzer display all numbers as positive, no matterwhether they are truly positive or negative ?I am having to cast each column to varchar to find out if there areany negative numbers being hidden from me :(I tried checking Tools/Options/Connections/Use Regional Settings bothon and off, stopping and restarting M$ Query Analyer in betwixt, butno improvement.Am I missing some other option somewhere ?
I have a table with a column ID of ContentID. The ID in that column is all NULLs. I need a way to change those nulls to a number. It does not matter what type of number it is as long as they are different. Can someone point me somewhere with a piece of T-SQL that I could use to do that. There are over 24000 rows so cursor change will not be very efficient.
hello. I have a database that a client developed that I need to pull data from. it consists of articles that fall into a range of 3 main categories. each article will have up to 7 different subcategories they fall into. I need to be able to sort by main category as well as by subcategory. But when I create the SQL query it gets really messy. I tried using WHERE Cat1= comm OR leg OR and so on, but there are seven categories so this gets very cumbersome and doesn't quite work. Is there a way to create an array or a subquery for this? I am a total newbie, so any help is much appreciated!
Hi all. I have the problem on query. This is my query.
select D.fullname, P.religion, E.empno from pspersonaldata as P inner join hremployees as E on P.dcno = E.empdcno inner join psdatacenter as D on D.dcno = E.empdcno where P.religion in ('Born Again','Baptist', 'Catholic')
How could I make a query that returns a result for either "Born Again, Baptist, or Catholic". The parameter would depend on the input of the user depending on how many religion the user inputed. If the user inputed Born Again and Baptist, the result is the employees that have a religion of Born Again and Baptist. Thanks -Ron-
I need to pass a parameter to a stored procedure that allows the user to select all store numbers or a combination thereof. The portion that selects all works fine. I am have trouble with the later. My code looks like this:
IF @StartDate IS NULL BEGIN Set @StartDate = GetDate() Set @EndDate = (GetDate ()+90) END Declare @StoreList TABLE ( CenterID int )
-- Get our Centers IF ( @Center = 'ALL' ) or ( @Center IS NULL ) BEGIN INSERT @StoreList SELECT DISTINCT POS_Site_ID FROM LVIGP.dbo.POS40108 (nolock) END ELSE BEGIN
INSERT @StoreList SELECT DISTINCT POS_Site_ID FROM LVIGP.dbo.POS40108 (nolock) WHERE POS_Site_ID = @Center END
the first if statement returns all of the store number like this CenterID 001 002 010 024 057
the second if returns nothing I tried using coalesce but it returns the store number like this: CenterID 001, 002, 010, 024, 057 This does not work with the rest of my program.
Can I create a report that offers users a choice for the parameter. I want to show a sales report based on either Fiscal year or Calender Year. Can I do that with one report that allows an option on which parameter to choose or do I need two reports.
I need an advice for an easy maintainable and highly flexible solution using SSIS. We're supplying our customers with an exportservice. The data is extracted from different tables, all with the same tableschema, fairly easy to create a foreach-container and iterate through the tablenames and extract data and use a flatfile destination to write it to...
But the not so easy part is to have different exportformats and still be using only one package. I could maybe use different ConnectionManagers for the FlatFileDestination, but that's not a very easy maintainable solution in my world. Our Customers will soon demand a webinterface where they can select necessary columns and apply different formatting for example they would demand the datetime to be '2006-12-24' or maybe '12/24/2006' etc. for alot of the available columns.
Any good suggestion on how to accomplish such a task?
I need to write a stored procedure with 20 parameters as input and it searches in a table . Most of the parameters or NULL , how do I write this procedure without using any dynamic queries.
Ex : To find a customer I have a proc which can accept 20 parameters like CustName, City, State , Phone , Street etc.
Im passing only Custname as parameters and other 19 parameters are NULL.How do I write the WHERE clause ?
Is it possible to have a parameter with one label but multiple values. For example:
Label Value ---------------------------------------------
Machinist (100,200,300)
Is it possible to set up an expression that when the user selects this label it will look for the job codes 100, 200 and 300 and return all employees in those codes?
I am working on SSRS. I need to open a new report from one report when user clicks on some particular summerized count link.
Its a sort of drilled down report. I am not getting how to pass the respected Ids (more than one) to the next report when user clicks on the link in the 1st report. These ids I want to use as a parameter (multiple) in the 2nd report to dump the rows from the database.
I have a report in which one parameter has with multiple selections (List of CheckBoxes). SSRS automatically adds a "Select All" value as the first option. I'm showing a User Type list, but for example, usually the user running the report will be selecting two or three sets of "User Types" (*), then I named those selections and put them in the list also. The list looks like: "Select All" IT Users (*) HR Users (*) Programmers DB Analyst... etc...
What I'm trying to do is that when the user selects "IT Users" (per example), then the options "Programmers" and "DB Analyst" will be checked automatically, because they belong to "IT Users" group.
Im trying to set up a report in visual studio 2005 which uses multiple parameters (6) on which the user can filter to get the information they want.
here is what i want to happen - I've tried to explain as best i can but i dont think i've done a very good job...please ask questions if things need clarifying:
the 6 parameters are - userid, printers, default printer, area, applications, supervisor.
these need to be able to be filtered on any/all/combination of those parameters. parameters are set up and data is accessible, however when i run the report and try and filter on these it only works if all parameters are set to "All" (this is made available through a UNION select statement), or if i individually select a value for each category. if i choose a combination of say userid =myname, printers = myprinter, default=all, area=all etc it will match if ANY of the criteria is matched (including the ALL criteria, therefore it will always display all the values). i need to it work so if i pick the userid and the printer it will only match records containing BOTH the values i select, not either, or if i choose just the area, it will only return those records that contain that department.
Below is the WHERE statement i am currently entering in
WHERE (AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (((AllUserData.nvarchar3 LIKE @Area) OR (@Area = 'All')) OR ((AllUserData.nvarchar4 LIKE @Default) OR (@Default = 'All')) OR ((AllUserData.ntext1 LIKE '%' + @Printer + '%') OR (@Printer = 'All')) OR ((AllUserData.ntext2 LIKE '%' + @Application + '%') OR (@Application = 'All')) OR ((@Application = 'All') AND (@Printer = 'All') AND (@Default = 'All') AND (@Area = 'All')))
and here is what Visual Studio automatically translates that into as soon as i execute the script:
WHERE (AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (AllUserData.nvarchar3 LIKE @Area) OR (AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (@Area = 'All') OR (AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (AllUserData.nvarchar4 LIKE @Default) OR (AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (@Default = 'All') OR (AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (AllUserData.ntext1 LIKE '%' + @Printer + '%') OR (AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (@Printer = 'All') OR (AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (AllUserData.ntext2 LIKE '%' + @Application + '%') OR (AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (@Application = 'All') OR (AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (@Area = 'All') AND (@Default = 'All') AND (@Printer = 'All') AND (@Application = 'All')
Note: AllUserData.tp_ListId references a specific row in the database which must be queried to get the correct information. so it must match on that before anything else.
any help structuring the logic i am using or better understanding the way visual studio/sql handles this kind of thing would be fantastic! thanks!
Using a Report Designer of the SQL Server 2008 connecting to an ORACLE database:
- I want to use Parameters filters with multiple Values but i get the error :
"FilterExpression for the data set 'DATAset1' cannot be performed. Cannot compare data of types System.String and System.Object[]. Please Check the Data Type Returned by the FilterExpression"
without the multiple Values it works but don't resolve my problem.
The filter configuration is =Fields!DT_OPERACAO.Value = =Parameters!FLT_Ano_Lectivo.Value
I receive several TXT files daily that need to update information in SQL Server databases. The process requires that all TXT files be appended to a master file and also update individual files' information based on the TXT file name. For example:
File TABLE1_x_ddmmyy.TXT (ddmmyy = date, x = "O" or "B") is to be appended to the master file and also update SQL table "TABLE1" by setting a flag for those records in the table that match a unique key that is provided in the TABLE1.TXT file.
In VFP, I had the following process in place: a) open the TXT file. b) read its file name and open the corresponding VFP file c) update the VFP file based on the key provided in TXT d) append the key to the master file. e) repeat c-d for next record in TXT f) repeat c-e for next TXT file
Using the same process with ADO takes a considerable time since I am processing one line at a time.
Is there any way to do this using a DTS package of some sort? How can I read the TXT file names in SQL Server?
User-B Custom fields: Blood type <char 3> Date of birth <date> Referred by <varchar 50>
Different users can have different custom fields in their address book. As you can see, while the standard fields for each user can be
stored in a single table. However, I have several methods by which I can store the CUSTOM fields.
------------------------------------------------ Method 1: Create 2 separate tables called CustomField and CustomValue:
CustomField has fields: FieldID <int> FieldName <varchar 25> UserID <int>
CustomValue has fields: ValueID <int> Value <varchar 50> FieldID <int>
------------------------------------------------ Method 2: Create a separate Field and multiple Value tables for each data type: CustomField, CustomCharValue, CustomIntValue, CustomMoneyValue, etc...
CustomField has fields: FieldID <int> FieldName <varchar 25> FieldType <smallint> (determines which TABLE, below, contains the data) UserID <int>
I'm thinking that while Method 1 will be easier to implement, Method 2 may offer me better performance if coded correctly. I'm going
to assume that I'll have at least 1-5 million records to work with over the course of my first year and I will need the ability to sort
records based on values in the custom fields as well.
My first question is: Which method should I be considering and is there an alternative or hybrid that I should be considering?
My second question is: What statements should I use in my stored procedure that will enable me to retrieve a list of USERID, CustomFieldIDs and their values as one resulting table that I can query at will and with solid performance?
Hi, I have this idea of using Dynamic SQL on a cross-tab and the following questions popped-up:
1) Is there a limit to the length of the statement the EXEC / sp_executesql command can execute? 2) Should I use cursors (Haven't used this one, I preferred work tables)?
Here are the details:
TABLE_SAMPLE RptDate DATETIME, SomeField CHAR(1), ID CHAR(8), RetVal VARCHAR(15)
SP Input: A date range that defines what the RptDates are: @DateFrom DATETIME, @DateTo DATETIME
[BLANK] - means that there was no record for that RptDate for the ID
Conditions: - The number of records per ID varies and depends on the number of RptDates covered by @DateFrom and @DateTo ID1 can have records for 02/26/2008, 02/25/2008, 02/22/2008 ID2 can have records for one, two or all of the same dates. etc...
I'm trying to create a DTS package that will let me import an Excel file. The user will be able to name the file the same name every time. But can the DTS package read a different worksheet name each time? Right now, if I use the Excel connection object in DTS designer, it wants to hard code the worksheet name.
Is it possible to set up the permissions to not allow a specific user to create schemas, but to allow that user to create tables and procedures and functions in one schema, and to create procedures and functions but not tables, in a different schema within the same database?