Showing posts with label item. Show all posts
Showing posts with label item. Show all posts

Monday, March 26, 2012

Ragged Hierarchy / Unbalanced Hierarchy - whats the difference and how do i process it ?

Q1) what is the difference between a ragged hierarchy and an unbalanced hierarchy ?

Q2)

I have a structure for items in the store

Each item can be classified into

Category

SubCategory

Class

Most items go down all three levels

but some are only classified into the top two categories

and a few are only classified in the Category classification

i have tried to create a Hierarchy for this

but when i review the results in the browser, it will only show me the results of the items that are classified to the bottom level - it does NOT show me the ones that are classified in only the top one or two levels

according to BOL

"To make a parent-child hierarchy ragged, use the SkippedLevelsColumn property of the parent attribute in the hierarchy to support the ragged structure."

but i have found that this has been removed from AS2005

(http://msdn2.microsoft.com/en-us/library/ms143229.aspx)

Skipped levels in parent-child hierarchies

The SkippedLevelsColumnproperty, which indicates how many levels to skip when creating a member under a parent in a parent-child hierarchy, is no longer supported.

so - how can this be done ?

Hello! To me a ragged or unbalanced hierarchy is the same.

You control this on each level in the user hierarchy in the dimension editor. Click on a level in the hiearchy and check the property "HideMemberIf"

Parent-Child dimensions is a different case because they have unnamed, recursive levels. Ragged and Unbalanced Hierarchies have named levels but with missing members or values in each level in the user hierarchy.

HTH

Thomas Ivarsson

|||

Thomas

thx for this

but can you please explain a bit more

i have set the HideMemberIf property on both the SubCategory and Class description to NoName - and this hides the blank entries (as expected)

But

when i put attribute relationships between the SubCategory and Category and between the SubCategory and Class onto the hierarchy (in the Hierarchies and Levels panel), then the original problem arises in that the entries are not shown in the cube browser

m

|||

Hello again. I have checked the Geography dimension and the Geography-hierarchy in the Adventure Works sample cube that is part of the installation of SQL Server 2005.

In this hierarchy you have the levels Country-StateProvince-City-PostalCode all with attribute relations to the parent and a HideMemberIf-property set to NoName on the StateProvince level. United Kingdom have no members in the StateProvince-level, like you can see in the browser. All other countries have. This example works as you expect so you must have another problem in your dimension.

The HideMemberIf-property will not be supported in the next release of SQL Server, according to books on line.

HTH

Thomas Ivarsson

Tuesday, March 20, 2012

Quote in input field yeilds error

Hello!

I have an input form that contains a textarea in which people can input the description of an item. They then click Insert or Update and the information is inserted or updated to a SQL Server database. Everything works fine unless someone includes a quote in the description. For example:

The item is Bob's computer.

The apostrophe in Bob creates a problem. I receive the following:

Incorrect syntax near 's'. Unclosed quotation mark before the character string '.

I understand the problem. How do I correct it?

Thanks!

PS I am using C#.Use parameters.

See here|||OF COURSE!! I knew I had done this at some time...thanks for JOGGING my brain!! :)|||I have the same problem, but I don't see how that tutorial would work for an imput text box. If the user types in something like "Mike's car" (without the quotes), it ruins the sql string. How can I code around, or get the server to accept single quotes or apostrophes?
Thanks,
Sean|||The previous link will in fact resolve the problem. Honest.

A poorer alternative is replacing all ' with two ' characters ('' - this is NOT a regular quote, but two single quotes). Doing this still allows SQL Injection attacks to occur.|||Sorry, but I don't see how to apply it to an update statement. Here's a piece of my code:


Sub btnSubmit_Click(sender As Object, e As EventArgs)
Dim strPurpose as string =txtPurpose.text
Dim MySQL as string = "Insert into tbl_ExpsReports (expsPurpose) values ('" & strPurpose & "')"
Dim myConn As New OLEDBConnection(configurationSettings.AppSettings("MSDBconn"))
Dim Cmd as New OleDbCommand(MySQL, MyConn)

MyConn.Open()
cmd.ExecuteNonQuery
MyConn.close()
End Sub

How do I allow the user to key in a single quote or apostrope into the txtPurpose text box? The tutorial seems to be geared towards a return rather than input statement.
Thanks,
Sean|||What you are doing is not that unusual:

Sub btnSubmit_Click(sender As Object, e As EventArgs)
Dim strPurpose as string =txtPurpose.text
Dim MySQL as string = "Insert into tbl_ExpsReports (expsPurpose) values (?)"

Dim myConn As New OLEDBConnection(configurationSettings.AppSettings("MSDBconn"))
Dim Cmd as New OleDbCommand(MySQL, MyConn)
Cmd.Parameters.Add("expsPurpose",strPurpose)

MyConn.Open()
cmd.ExecuteNonQuery
MyConn.close()
End Sub
</code>|||So, what you are saying is, if I use a perameterized insert statement, then the user can key in an apostrophe or single quote? Cool! ;^]|||Yes. And prevents SQL Injection.|||SQL injection... hmmmm... sounds bad.