Showing posts with label solution. Show all posts
Showing posts with label solution. Show all posts

Wednesday, March 21, 2012

Dynamic Members Security

Hi All,
I have a working solution with user-defined security. When user connects to a cube, a list with allowed members is created(retrieved from table) and returned as set to AS. Everything works fine.

Problem is that members are retrieved only at connection time. When I change my table with allowed members later, I would like to force AS to re-read this information again. Of course I can restart AS service or do full process of cube.

Does anybody have an idea?

Thanks,
Radim

Have you tried just reprocessing the dimension affected? What are the specifics of the solution?

|||That's very correct. Processing is possible solution but since I have many concurent users I didn't want to disrupt them. But yesterday I played with it more and I discovered that it's only necessary to do Process index. That's enough to force re-read of allowed members.

Thanks for contribution.

Radim

Friday, March 9, 2012

dynamic field positioning

Good day everyone,

I'm can't seem to find a solution for this. Using the scripts( formula editor ), I needed to programmatically edit the position of a field. Does anybody have an idea?

Here's what I did.

I created a new formula field(@.denom), then I placed it at a specific location in the report.

When I meet some conditions, the field's position should change.

Any comments will helpCreate two formulae with same coding
Put them in different position
In the suppress event of them write the query that meets the condition. Suppress one and dont suppress other

dynamic declaration of table type -- any solution?

We got to build a table dynamically using the following code,
====================================
declare @.Part int
declare @.examId int
declare @.tSQL varchar(2000)
declare @.colname varchar(100)
select @.Part = 6

select @.tSQL = 'declare @.Report table ('
Declare mycolumns cursor for
SELECT SubjectCode FROM tblSubjectsMaster WHERE (Part = @.Part) order by SubjectName
OPEN mycolumns
FETCH NEXT FROM mycolumns
INTO @.colname
WHILE @.@.FETCH_STATUS = 0
BEGIN
Select @.tSQL = @.tSQL + @.colname + ' varchar(100),'
FETCH NEXT FROM mycolumns
INTO @.colname
END
CLOSE mycolumns
DEALLOCATE mycolumns
Select @.tSQL = @.tSQL + ' Total int, Result varchar(200), Place int)'
exec(@.tSQL)
==================================
Then in the next line, I'm giving the following line.
select * from @.Report
which is gioving the following error
======================
Must declare the variable '@.Report'.

Assumption is that there is some scope related problem...But the requirement is demanding to think in this lines.

Any body of any guess on any resolution.

Thanks in advance.

Thanks & Regards
Srinivasa ReddyHi,

A table variable just exists until a go or exec command are executed. You have to create a temp table.

/Mats

Friday, February 24, 2012

dynamic connection string

hi all,

i've been reading through the forum on this subject but couldn't find the solution. i'm using RS2005.

it's mentioned that dynamic connection string is not applicable for shared data source. is there a workaround for this?

thanks!

Dynamic connection strings cannot be used with shared data sources.

Other suggestions can be found in this related thread: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=16395&SiteID=1

-- Robert

|||

Thanks Robert for your reply.

however, do methods for RS2000 apply for RS2005? i've never used RS2000 before and i'm not sure where to start either.

Thanks!

|||

Yes, everything mentioned for RS 2000 works for RS 2005 the same way.
RS 2005 offers expression-based connection strings in addition.

-- Robert

|||

I wrote an application using VS2005 that has a generic report viewer and rdlc files stored in a database with the stored procedures necessary to run each report.

Then I took the report, replaced the dataset stored in the rdlc file programmatically with the generic dataset which accepts the result of the stored procedure and use it to populate the report.

It wasn't that straight forward, but now it works dynamically and I have an application now which I can add a new record to my database storing my rdlc files and stored procedure names and the list of reports that drop down in my application is completely dynamic, including parameters required appearing in a datagrid with controls for calendars and drop-down lists.

Just an idea of how you might get that dynamic dataset.

dynamic columns: in search of the Tatrix data region

This subject has been much discussed but I haven't found a solution
that really works in my situation.
What we need here is a hybrid table/matrix data region with static
columns on the left and (at least) one dynamic column on the right.
Thus do I reveal my cultural bias and no doubt my ignorance of
Reporting Services as well. Maybe this can be done, but I haven't
figured it out.
Wishlist for this "Tatrix" data region:
1) No corner cell
2) A header row that runs straight across the top like a table
3) Header row repeats on each new page
4) Ability to define n static columns at left or right of region
5) Ability to define at least one dynamic column at right or left of
data region, respectively.
In my case I have an inventory with the usual ItemID, ItemName,
ItemCategory fields in the Dataset. These and other fields are
enterprise-level, common across all business units. An ItemRetailPrice
field is potentially unique to each business unit. Therefore I'd like
to have a Tatrix that would display the enterprise-level fields as
static columns and the business-unit-level field(s) as dynamic columns.
Ideally you could have repeating groups of dynamic columns
growing/shrinking out to the side.
The only kludge so far that looks something like what the customer
wants is a Matrix with an Image in the corner cell, simulating the
headers for the static columns. It's hard to get the Image right since
the dimensions of the corner cell change from format to format. The
corner cell graphic seems to shrink on export to Excel. There's no way
to dynamically change the embedded Image to display the product group
you're looking at in a given report.
Apologies if this has been done and described and I didn't find it,
Highly ObscureHi,
I'm sorry that I could not find a way to do this with Matrix in Reporting
Services. You are welcome to send suggestions for product enhancements that
you would like to see in future versions of Microsoft products to us by
submitting MS Wish to mswish@.microsoft.com. By submitting your concerns,
you can get your voice into the design plans for upcoming versions.
Microsoft takes customer requests and suggestions very seriously. MSWISH is
your voice to the development team. A significant number of the design
change requests come from our customers through the MSWISH alias and the
MSWISH web site. http://www.microsoft.com/mswish. I encourage you to submit
this request.
Sincerely,
William Wang
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
This posting is provided "AS IS" with no warranties, and confers no rights.
--
>NNTP-Posting-Date: Thu, 10 Mar 2005 08:20:34 -0600
>From: "HighlyObscure" <HighlyObscure@.nospam.nospam>
>Subject: dynamic columns: in search of the Tatrix data region
>Newsgroups: microsoft.public.sqlserver.reportingsvcs
>User-Agent: XanaNews/1.17.1.2
>MIME-Version: 1.0
>Content-Type: text/plain; charset=iso-8859-1
>Message-ID: <-oGdnd2P_48vyq3fRVn-hw@.giganews.com>
>Date: Thu, 10 Mar 2005 08:20:34 -0600
>Lines: 42
>X-Trace:
sv3-AdcAxaYs02709d1QLmyISb8L5LZ1SscpiD0Uxn9maeA2kWFvFAuwfshGnq4q+8NXAFKwvaVH
CDw2zH1!3UOd+sBB1baL2C/VrYQhkqjo1KZExYUfZWDixZF1cqFUrf7vda8YFYzxJeLF9A==>X-Complaints-To: abuse@.giganews.com
>X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
>X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
>X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
>X-Postfilter: 1.3.32
>Path:
TK2MSFTNGXA02.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP0
8.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.c
om!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews

Wednesday, February 15, 2012

Dynamic (on the fly) query

Hi all. I'm currently encountering a problem in attempting to find a solution for a dynamic or on the fly query. I understand how you can make a static query and return it as a dataset; for example, say you have a field where a user enters a name on the front end and the db returns the results:

Dim queryString As String = "SELECT [Table].* FROM [Table] WHERE ("& _
"[Table].[Name] = @.Name)"

But what if I have multiple items I would like query based upon what the user picks. For example, say you have five fields: Name, ID Number, Date, Address, and State. Say the user wants to pick all data with a date between Jan. 06 to April 06, with the name of Tom, and in the state of CA. But then next time, the user only wants all data with the name of Susan. So the query is always changing and I am not sure exactly how to go about it. I guess I sorta want similiar functionality as that of the Custom Auto Filter in Excel. I've been reading a couple of the forums and I think people are using a string to pass to query the database. But I am still vague on how to approach this. Any help would be greatly appreciated!

string sql ="select pt.ProjectTaskID, pt.EmployeeID, pt.ProjectID, pt.TaskID, pt.TaskDate, pt.TaskLength " +"from ProjectTask pt, project p where pt.EmployeeID = @.Employee and (pt.TaskDate >= @.startDate and pt.TaskDate <= @.endDate) " +"and pt.projectid = p.projectid"; cmd.Parameters.AddWithValue("@.Employee", nGlobals.TheUser.EmployeeID); cmd.Parameters.AddWithValue("@.startDate", nStartDate); cmd.Parameters.AddWithValue("@.endDate", nEndDate);if (nPrimary > 0) { sql = sql +" and p.biostatPI = @.pi"; cmd.Parameters.AddWithValue("@.pi", nPrimary); }if (nClinicalPrimary > 0) { sql = sql +" and p.clinicalPI = @.clinical"; cmd.Parameters.AddWithValue("@.clinical", nClinicalPrimary); }if (nDept > 0) { sql = sql +" and p.departmentId = @.dept"; cmd.Parameters.AddWithValue("@.dept", nDept); }if ((nGrant !=null) && (nGrant.Length > 0)) { sql = sql +" and p.grantNumber = @.grant"; cmd.Parameters.AddWithValue("@.grant", nGrant); }if ((nProtocol !=null) && (nProtocol.Length > 0)) { sql = sql +" and p.protocolNumber = @.protocol"; cmd.Parameters.AddWithValue("@.protocol", nProtocol); }
|||

SELECT Name, [ID Number], [Date], Address, State FROM [Table] WHERE Name=ISNULL(@.Name, Name) AND State=ISNULL(@.State, State) AND [Date] BETWEEN @.Date1AND @.Date2

In your parameters, you need handle the default values for these parameters. Hope this gives you one direction to work with. You can also use COALESCE function instead of the ISNULL function in the where clause .

|||

In the above code, there are 5 optional selection parameters. If a value isn't blank, it's added to the where clause, and the appropriate parameter is added as well. There's a bit of overhead, because you're executing different SQL with almost every query.

A more efficient, but more complex method would be to use a stored procedure, with the base select selecting into a temp table, and for each not null criteria, deleting rows from the temp table that don't match the criteria.

|||

Ok, try this. Use a stored proc, like this.

-- first, give it every input parameter you will ever want to use to select from this table.

create procedure sometableselect (
@.sometableid int=null,
@.field1 int = null,
@.field2 varchar(50)=null,
@.fromdate datetime=null,
@.todate datetime=null,
@.sort varchar(500)=null
)
as
set nocount on
set ansi_warnings off
declare @.sql varchar(500)

-- This table below should be everything you ever wanted to know about the records
-- in this table. Get all related information and put it in here.

create table #temp1 (

Sometableid int,
field1 int,

field2 varchar(50),
recorddate datetime,
foreignkeyID int,
foreignkeydescription varchar(50),
reccount int
)

-- then insert the records you want to select
insert into #temp1 (
field1,
field2,
recorddate,
foreignkeyid
)
select
field1,
field2,
recorddate,
foreignkeyid)
from sometable
where (@.sometableid is null or @.sometableid=sometableid)
and (@.field1 is null or @.field1=field1)
and (@.field2 is null or patindex('%'+@.field2+'%', field2)>0)
and (@.fromdate is null or @.fromdate <=recorddate)
and (@.todate is null or @.todate >=recorddate)

update #temp1 set foreignkeydescription=fk.description
from foreignkeytable fk where fk.foreignkeyid = #temp1.foreignkeyid

update #temp1 set reccount = (select count(*) from #temp1)

select @.sql ='select * from #temp1 '
if isnull(@.sort,'') <>'' select @.sql = @.sql + ' order by ' + @.sort

exec(@.sql)
drop table #temp1
set nocount off
set ansi_warnings on

You call it from code like this:
query = "TableSelect "
query = query & "@.field1=" & cstr(value1)
query=query & ", @.field2='" & value2 & "'"

There are also other ways to call it, using parameters. I find building a query string to be more convenient and, in case of doubt, I can just copy and paste the query string into Query Analyzer and run it manually to see what it does.

The effect is that it will select by whatever parameters you use -- in combination -- and it will ignore those you don't use. If you don't give it a parameter, it will assume a default value of null, which means the selection criteria will drop out of the selection. If you call it with no parameters, it returns every record in the table, which makes it easy to run simple tests.

The reason you return EVERYTHING related to the record in the stored proc is to make it easier for the front-end programmer. If you write them like this, then one stored proc can be used to select records from the table almost anywhere in a typical application. One stored proc does it all.

The @.sort parameter allows you to return the recordset in whatever order you want by passing it from the front end. The @.sort may be any valid ORDER BY clause for the #temp1 table.

I also return the reccount as the number of records in the recordset. This isn't strictly necessary, but it comes in handy sometimes when you need the number of records on the front end.

If you start out an app by routinely building one of these procs for each table when you develop an app, you will find that it makes building the front end a breeze.


@.

|||Thanks all