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

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

Nested CAML Querie results in exception " Some part of your SQL statement is nested too deeply. Rewr

Posted By:      Posted Date: October 27, 2010    Points: 0   Category :SharePoint


I am trying to mimic SQL"IN" operation using CAML. Lets take a scenario where we need fetch all the ListItems with ID within a list of IDs. The target list is realy large ( 50k records)

Possible options are from the Working with large list Whitepaper

-> CAML (Object model) -> CAML (using Webservices) -> Portal Site Map Provider -> Search API

The Custom webpart that we are developing is on live data ( NO search API) and query is user dependent (No Portal Site provider)

As our code is deployed on to the server, we can use SPobject model SPQuery, but as CAML deosn't support "IN" Operator and not more than two logical operators in we have to nested query.

When the nested query hits the 478 nested ORs then the exception is raised

"Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries "

Firstly the Row lmit 2000 is resulting in multiple queries and on top of it, spliting it further results in performance impact.

Is there any other better solution???

View Complete Post

More Related Resource Links

Sql DateTime2 to .NET DateTime conversion results in out-of-range exception

I posted it in C# General because I thought that the subject was not Sql Smo related, although I use Smo extensively even in this routine for connection. Unfortunately after a few days no constructive suggestion has been advanced. Two posts the thread collected are not helpful. I am wondering if Alok or someone else with the status of MSFT Sql Server developers take a look at this very importan problem for me which became a stumbling block.Thanks. AlexB - Win_7 Pro64, SqlSer64 WinSer64

Internal server error exception on search results page when no language is set in browser

We have some users who receive an internal server error exception when they enter a search query on our SPS 2010 site. The SharePoint log shows the following: Internal server error exception: System.ArgumentNullException: Value cannot be null.  Parameter name: The property RequestedLanguage cant not set to NULL     at Microsoft.Office.Server.Search.Query.Location.set_RequestedLanguage(CultureInfo value)     at Microsoft.Office.Server.Search.WebControls.CoreResultsDatasourceView.CreateLocationList()     at Microsoft.Office.Server.Search.WebControls.CoreResultsDatasourceView.SetPropertiesOnQdra()     at Microsoft.Office.Server.Search.WebControls.SearchResultsBaseWebPart.EnsureWebpartReady() System.ArgumentNullException: Value cannot be null.  Parameter name: The property RequestedLanguage cant not set to NULL     at Microsoft.Office.Server.Search.Query.Location.set_RequestedLanguage(CultureInfo value)     at Microsoft.Office.Server.Search.WebControls.CoreResultsDatasourceView.CreateLocationList()     at Microsoft.Office.Server.Search.WebControls.CoreResultsDatasourceView.SetPropertiesOnQdra()     at Microsoft.Office.Server.Search.WebControls.SearchResultsBaseWebPart.EnsureWebpartReady() After some more diggin

Creating workflow in SP Designer 2010 results in Exception from HRESULT: 0x80131401


The workflow is a 1 step Approval workflow. I'd published it a few time and it worked just fine. I then made a change to an "Email task notification" step.

I get a dialog when I try to publish the workflow:

Workflow Error
Errors were found when compiling the workflow. The workflow files were saved but cannot be run.
(43, 3) Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401))

I tried the "Check for Errors" button and I get:
The workflow contains no errors.

Error dialog
Check for Error dialog

Anyone have any clues as to where I might start looking for clues? Nothing has been returned by the usual search engines...

I've just tried to create a brand new workflow and it's still giving me the above dialogs. :'(

The type initializer for 'Nested' threw an exception for BDC USING Application Definition Designer



Is anyone know what this error could mean?

The type initializer for 'Nested' threw an exception.

when i am executing instance method using "Application Definition Designer" for BDC.

Same ADF file works fine locally but getting above error message when executing on server.(both sharepoint are different) and install on different machines.

When executing BDC catalog file in sharepoint. We are getting below error message.

An error occurred while retrieving data from CustomerBDC_Instance. Administrators, see the server log for more information.

Event log:

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">

- <System>

<Provider Name="Office SharePoint Server" />

<EventID Qualifiers="0">5703</EventID>




<TimeCreated SystemTime="2010-10-22T12:20:39.000Z" />



<Computer>[LOCAL COMPUTER ADDRESS]</Computer>

<Security />


- &l

Microsoft's Collaborative Application Markup Language (CAML) Loop

discovered an interesting error recently while working with Microsoft's Collaborative Application Markup Language (CAML) that, surprisingly, had received no ink. Partly what surprises me about this is that the error may require you to rewrite large sections of your code if you haven't previously considered this SharePoint limitation. I'll start with some context, but first of all the error is:


Every self-respected programmer should include exception handling techniques. Sometimes your application will generate an error. Regardless of who was responsible for this error, the programmer or the user, it is up to the first to include the necessary exception handling techniques to keep his/her program from crashing. The .Net environment provides useful techniques for avoiding disastrous errors such as try-catch statements and user-defined exceptions.

Global Exception Handling with ASP.NET

After your global exception handler has done its work, you'll want to redirect the users of your website to a friendly page that tells them that something has gone wrong, and then provide them with customer support information as well as a link back to your web application's home page.

SQL Server 2005 Try and Catch Exception Handling

I'm pretty excited to see that there is some real error handling for T-SQL code in SQL Server 2005. It's pretty painful to have your wonderfully architected .NET solution tainted by less-than-VBScript error handling for stored procedures in the database. The big difference being the addition of TRY..CATCH blocks. Let's take a look:

Binding Nested Listviews in MVC ViewPage


I am a longtime .NET developer but for big applications and services.  This is my first asp.net project and I have chosen MVC.   I have a need for nesting a ListView within a ListView.  In this simple catalog app, I have EF 4 Entities that are Categories, SubCategories, ItemTypes, and Items.

My goal is to display a 5 column layout of SubCategories with their ItemTypes below them in a ViewPage.  I did just fine with it done out in C# as server directives such as:

    var subcats = Model.SubCategory.ToArray();
    var nrSubCats = subcats.Count();
    var rows = (nrSubCats/5) + (((nrSubCats % 5) > 0) ? 1 : 0);
    for (var row = 0; row < rows; row++)
    { %>
        <div style="width: 100%; float: left; clear: right;">
        var start = row * 5;
        for (var i = start; (i < start + 5) && (i < nrSubCats); i++)
        var subcat = subcats[i];
            <div style="float: left; clear: right; width: 20%; margin-left: 5;">
                <h2> <%:subcat.Name%></h2>
                    foreach (var its in subcat.ItemType)

MVC2 issue - Stuck. Trying to create a cms with nested partials


I am currently trying to display multiple items on a single page. I am not sure as to how to tackle this. What I have is a database table that has all the page data in. I have this run as a PagesController and this works fine. However what I would like to do is, if say the Products page is selected via the menu, I want to pull back not only the Products page html but also get all the products, and even be able to pull them through via category. I was trying to use a partial view, but I can't get it to work. The same would be for other pages, having partial views to display the other content, ie if Gallery is selected, the page html for Gallery shows and it then can push to a partial view that pulls all the gallery images from the gallery db table and so on. 

Maybe I am tackling this the wrong way. I have the pages stored in the db to allow for a CMS system I have setup. Maybe I need to use models for all the other items(Products, Gallery, Videos and such) and use the partial for the page html?

Any help would be greatly appreciated as I am confused.

reader.getordinal("column_may_not_exist") how to catch the exception?



would any body please help me to catch the exception if the column doesnot exist as my table columns are not static.

sometimes its throwing me indexoutofrange exception as the column doesnot exist

thanks for the help guys

Need Syntax To Make Results of LINQ Union Return Non-Generic Type



I have the below SQL which works just fine:

SELECT     Message, CreateDate, AccountId, AlertTypeId
FROM       dbo.Alerts
SELECT     TOP (100) PERCENT Status, CreateDate, AccountId,
                          (SELECT     10 AS Expr1) AS AlertTypeId
FROM         dbo.StatusUpdates
WHERE AccountId = PassedInParameter

I have been going about trying to convert the above into a LINQ method and am having problems with return types.
As the above SQL illustrates, I am querying two distinct LINQ tables - Alerts and StatusUpdates -
and then attempting to perform a Union on them. In order to do the union in LINQ, I have to have agreeing types. So, I
am using "var" to make the results of "alerts" and "updates" generic before the union.  

public IList GetStatusUpdatesAsAlertsByAccountId<T>(Int32 accountId)
            using (WorkbookDataContext dc = _conn.GetCont

sqlDataReader dos not get results


I am trying to run a stored proc from this function. When I run it thorugh the debugger I can see that myReader.HasRows = true and myReader.FieldCount =14.

But the control does not go in the loop while (myReader.Read()) where I am trying to read Version field returned by the stored proc.

Pls check me code and suggest correction. Thank You.

private static int Get_CaseInfo(string CaseNum)
            int Ver = 0;
            String myConn = ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString();
            SqlConnection conn = new SqlConnection(myConn);
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = System.Data.CommandType.Text;

            SqlDataReader myReader = null;
            String stmt1 = "EXEC [REPORTS].[CaseInfoByCaseNo_Get] @CaseNo = '" + CaseNum + "'"; 
            cmd.CommandText = stmt1;
            cmd.Connection = conn;
                myReader = cmd.ExecuteReader();
                while (myReader.Read())
                    Ver = (int)myReader["Version"];

            catch (Exception)
            return Ver;         

displaying xsl results in browser


Hi guys,

How can I test what my xsl spits out in the browser, rather than just viewing the xsl itself?


Error while using exception handling block el 4.1


Hi Folks,


i am trying to use tyhe exception handling block of Enterprise library 4.1.


I just createda polisy and used IndexOutOfRangeException and added a replace handler and a logging handler to it.

I am using the NotifyRethrow PostHandlingAction to the exception.


During runtime I am getting an exception on the HandleException event, The exception is added below:



Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 42:             catch (Exception ex)
Line 43:             {
Line 44:                 bool reThrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy");
Line 45:         

Nested Tracers - is there a way to only log the outer trace?



I have some nested tracers. The outer one has a category of 'PageTrace' and the inner ones have categories of 'DBTrace'. When I set the outer category source to 'All' I get both traces. When I switch on the inner trace, I just get the inner trace.

So, my question: is there any way to just log the outer trace events, i.e. the Page Traces.




userprincipal.changepassword throws exception


Hi all,

      userprincipal.changepassword(oldpassword, newpassword);

gives error: that is Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied. (Exception from HRESULT: 0x80070547)

but userDirectoryEntry.invoke("ChangePassword", new object[] { oldpassword, newpassword });

      userDirectoryEntry.CommitChanges works fine.

Any one please tell me the reason behind this.

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