.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Pivot a Result Set

Posted By:      Posted Date: September 30, 2010    Points: 0   Category :Sql Server


i have a query which gives the output as below

   Screen          Value
Bill View        320
primary view        272
Network                216
detail view         191
Bill Screen        113
Promotions        86
Information         61

i wanto pivot these results


screen          Bill View   primaryview    Network    detail view      Bill Screen   Promotions       Information                                                                                                                                   &nb

View Complete Post

More Related Resource Links

Active Directory and .NET: paging the search result

Hi everybody!

I have a question about Active Directory in .NET
For my project I need to fetch results from Active Directory search page by page, because later I would need to bind it to the pageable DataGrid.

I tried to use .NET library DirectoryServices for that, but paging provided by this library is transparent to the user and is used only to increase the efficiency of searching, when results are too big. I.e. I cannot tell the DirectorySearcher to give me first page, then the next or previous page, it returns me all resulting pages in one bundle.

However, what I need is to explicitely get page after page directly from the AD searcher and to be able to go at least one page forward or backward.

The solution with copying all results to the DataBase and then do the paging is not accepeted by the clent, since it is too inefficient. And since it's a Web app, I cannot keep results in memory either.

I found some hints about COM Interface, but I could not find good and detailed examples or explanations. I aslo found this line of code: DirectoryServices.Interop.IDirectorySearch.ExecuteSearch(), but I don't know which libraries should i add to be able to compile this code.

If somebody could help me out with that problem, any suggestion is welcome, 'cause this issue is eating me alive :)

Thank you!

insufficient result space to convert uniqueidentifier value to char


Hi guys,

       Look, I've been trying to insert new values while I create a new user with a createuserwizard, but I've been getting this error over and over again:

"insufficient result space to convert uniqueidentifier value to char"

       The code that does it is the following:

  protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
TextBox UserNameTextBox = (TextBox)CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName");

SqlDataSource DataSource = (SqlDataSource)CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo");

MembershipUser User = Membership.GetUser(UserNameTextBox.Text);

object UserGUID = User.ProviderUserKey;

DataSource.InsertParameters.Add("UserId", UserGUID.ToString());


      But when I debug, the error is thrown before reaching the previous code, so I suppose the error is in the SqlDataSource, look:

      <asp:SqlDataSource ID="InsertExtraInfo" runat="server" Co

reading the result of a web service (XML)


Hi all,

I registered for a service that returns me the geolocation of the visitor and i process it in my exe application (c#).

But i dont know how to read that data in cs?

Here is the link that i send : 


and returning page content ;  

<?xml version="1.0" encoding="UTF-8" ?>
  <provider>Turk Telekom</provider>

Use DB query result to generate Jquery required lines of code



I 'm gonna query database for photo records. each record include "photo path" where imagesURL  stored in string format

 I Choses my favorite Juqery plugin to show images. Plugin needs some lines of code like below.

How could I  generate these lines

$(function() {
sleep: 2,
fade: 1
}, [
{ src: 'picture1.jpg' },
{ src: 'picture2.jpg' },
{ src: 'picture4.jpg' }

Linq to sql does not return appropriate multiple result sets with "If exists" conditions in the stor


Hello All,

I have a stored proc that returns 4 resultsets, they are in the format.

ALTER PROCEDURE [dbo].[pGetManagerEmployeeSummaryDummy]

    @ManagerStaffID int,
    @PeriodID int



IF EXISTS (select 1 from dbo.temployee e
    inner join dbo.temployeedetail ed
        on e.staffindividualid = ed.staffindividualid
        and ed.periodid = @PeriodID  
    inner join Incentive.tRole r
        on rm.IncentiveRoleID = r.RoleID
    where ed.ManagerIndividualStaffID = @ManagerStaffID
    AND r.RoleID = 1) --Closer
        SELECT e.StaffIndividualID, e.LastName, e.FirstName, r.RoleName, e.xname, e.yname

from dbo.temployee e

inner join dbo.temployeedetail ed
            on e.staffindividualid = ed.staffindividualid
            and ed.periodid = @PeriodID

where ed.ManagerIndividualStaffID = @ManagerStaffID

How to filter the search result based on a column value?

I do have search scope scoped at a list which contains attachment. I will use this scope to search (full text search) on this list then I need to filter the result based on a column which is in the same list. How do I do that? Thank you.

Search result show unauthorized Files Share


Hi All,

I configured a FileShare content source, the crawl about this source works very fine, but when a end user perform a search on it ,he can show into the search result files that are no access on the file server, but when he click on it of  course he received an access is denied.

How I can filter the search result about FileShare content source to see only files with authorized access?

Thank you for your help,





Pass the server variable to search core result web part


I'd like to custom the search core result web part to filter results based on the log on user name.

It can easily be done in Dataview web part.

However the search core web part doesn't accept "<parameterbining>" to pass in the server variable [logon_user]. I can't figure out how to use <xsl:param> to get this server variable either.


Any ideas? Thanks a lot!

If you get confused, listen to the music play...

Is there a way to get search result items to reflect the discussion they came from, not just the rep


What I'd like to do is somehow affect MOSS search such that when it finds relevant items that come from replies to a discussion, it references the original discussion itself, rather than the reply?


Thanks in advance


On New Item form, select item on choice dropdown based on query result.


I posted this on Experts Exchange awhile back with no answer, so here's hoping someone here has an idea :)

So I've mostly figured this problem out, but I need some help in getting over the hump... note that I'm using JavaScript to do this (SPServices) on SharePoint 07'.

I'm on the New Items page of a list. Based on a user's selection in a "Teacher" dropdown, I'm doing the following:

1.) Get the value of the Teacher field and several other fields (School and Visit Date)
2.) Run a CAML query based on those fields to find the last list item entered for that Teacher

So here's where I'm stuck...

I have 10 choice fields, all with choices 0, 4, 7, and 10. Depending on what they were set to in the last entered item (which I queried), I want to set the selected item on each of those dropdowns to equal that. So "Score 1" was set to "4" on the la

Net Framework 1.0 Error 1904 during setup mscoree.dll H-result 2146232576

I cleaned off all my .Net framework files with the .Net framework cleaner. I then started at 3.5, installed it, went well, installed 3.0, went well, installed 2.0, went well, installed 1.1, went well, then, tried to install 1.0 redistribution package for my windows xp home and it stopped at almost the very end saying ERROR installing 1.0 ERROR 1904 system32\mscoree.dll failed to register. H-result 2146232576. I tried renaming it and installing the 1.0 again but still get the same error. i tried using the IGNORE option, it said it installed but i know the mscoree.dll isn't working. i used the installer cleanup tool also to no avail. i deleted the URTTemp folder and tried a reinstall. This didn't work either. Anyone know what I might can do to get this corrected? I have not done anything myself in the registry. I have used RegCure and registry mechanic but Net Framework 1.0 still gave the error when I tried to install. Any help appreciated. I did read something about 1.1, 2.0,3.0 or 3.5 might have a newer mscoree.dll file and that night be why I can't register the one I have. I need the 1.0 version 3705 though as one of my programs uses it. Also, i am now not able to put any of the updates on my computer. it downloads them but they fail to install. Example, net framework 2.o service pack 2, net framework 3.5 service pack 1, and net framework 3.5 family update. Thanks....

PredictCaseLikelihood - strange result for a simple dataset

Hi, I have a some numbers between 1 and 431 and I want to use PredictCaseLikelyHood to determine the chances that any new number is a valid member of the existing set. My current dataset looks like this: 1 1 1 2 3 3 3 3 4 5 5 6 7 8 10 10 10 10 11 11 12 13 15 15 20 20 20 20 20 20 20 20 20 20 20 22 25 25 25 25 27 30 30 30 30 35 40 40 42 45 45 50 50 50 50 50 50 50 50 50 50 50 58 60 73 80 80 89 90 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 116 140 155 155 200 431   I use clustering to train the model with no holdout set. And I use the Mining Model Prediction Tab to test the PredictCaseLikelihood (normalized) result with a singleton query. As expected, when I enter new numbers between 1 and 431 the returned probability by PredictCaseLikelihood is very high (approx 0.99), however, when I enter positive outliers like 2000, the likelihood is INCREASED to 1, and if I give 2500 and above the likelihood is NaN. Any idea what is causing this strange behaviour? Is my dataset not fit for clustering and in that case why? I use SSAS 2008.   Thanks for any advice, Jørgen      

Pivot w/o aggregation...query not working

Hi all--Given this query, I need to make this query into a pivot table: select Personnel_id, First Name, Last Name, E-mail, Division, Region, Country, Manager, Question, Answer, Date Completed from #pivot where Question Answer 01. Received File No 02. Read File Yes 03. Signed File Yes ... Needs to look like this: Personnel_id First Name ... 01. Received File 02. Read File 03. Signed File ... Test01 Test No Yes Yes I have the following pivot query: SELECT [Personnel_id] ,[First Name] ,[Last Name] ,[Email] ,[Division] ,[Region] ,[Country] ,[Manager] ,[Question] ,[Answer] ,[Date Completed] FROM (SELECT [Personnel_id] ,[First Name] ,[Last Name] ,[Email] ,[Division] ,[Region] ,[Country] ,[Manager] ,[Question] ,[Answer] ,[Date Completed] FROM #pivot) topvt PIVOT (MAX([Personnel_id]) FOR Answer in ([1],[2], [3], [4], [5], [6], [7], [8] , [9], [10])) as pvt ORDER BY pvt.[Personnel_id] I get this error: Msg 207, Level 16, State 1, Line 83 Invalid column name 'Personnel_id'. Any ideas? Thanks!

Vertical Result Set

hi all...  Is it possible to get results vertically rather than horizontally... I have a table with over 70 colulmns I have to display top 3 records vertically.. I could get columns arranged vertically by using  information_schema.columns Any help is greatly appreciated.

Using Pivot to arranging data

Hello, I am attempting to optimize a selection query and I thought I would try a PIVOT. My question is simply is this the best way to do it? If not, why and what may be better? Please note the Tmstmp column is not necessarily spaced evenly like this example. Sample table:   Declare @temp table (Tmstmp datetime, Value integer ) INSERT INTO @temp (Tmstmp, Value) VALUES ('01/01/10',1) INSERT INTO @temp (Tmstmp, Value) VALUES ('01/02/10',2) INSERT INTO @temp (Tmstmp, Value) VALUES ('01/03/10',11) INSERT INTO @temp (Tmstmp, Value) VALUES ('01/04/10',1) INSERT INTO @temp (Tmstmp, Value) VALUES ('01/05/10',3) INSERT INTO @temp (Tmstmp, Value) VALUES ('01/06/10',5) INSERT INTO @temp (Tmstmp, Value) VALUES ('01/07/10',11) INSERT INTO @temp (Tmstmp, Value) VALUES ('01/08/10',1) INSERT INTO @temp (Tmstmp, Value) VALUES ('01/09/10',2) ;With CTE as ( SELECT t1.Tmstmp as StartDate, t2.Tmstmp as EndDate, t1.Value as Start_Val, t2.Value as End_Val, Row_Number() Over(Partition By t1.TmStmp ORDER BY DateDiff(day,t1.TmStmp,t2.TmStmp)) as Seq FROM @temp t1 INNER JOIN @temp t2 ON t2.Tmstmp > t1.Tmstmp WHERE t1.Value = 1 AND t2.Value = 11 ) SELECT StartDate, EndDate, [2] as TmStmp2, [3] as TmStmp3, [4] as TmStmp4, [5] as TmStmp5 FROM ( SELECT a.StartDate, a.EndDat

An exception occurred during the operation, making the result invalid

Hi I am using WCF services with WPF, both are .net 4 versions. I am calling asynchronously, During method calls, sometimes I get the following error Void RaiseExceptionIfNecessary()---An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() I tried alot to find the reason , but unable to find as it is unpredictable and inconsistent. Seeking for kind help from WCF guruzzz... Regards Zee

Dynamic Class with Linq query Result

Hi, var   query = db.Customers.Where( "City == @0 and Orders.Count >= @1", "London", 10). OrderBy( "CompanyName"). Select( "New(CompanyName as Name, Phone)");    I am using this query as a sample which returns a dynamicclass type, and i need this should to converted to a list collections or datatable etc., As i am holding it in my wcf service with linqtosql as dataaccesslayer. Trying to send the results to the UI which i have consumes this service. Kindly help me in this. Thanks query = db.Customers
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend