SqlServer Notes

The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
—–

operation is not valid due to the current state of the object=

——
http://snahta.blogspot.com/2009/04/unable-to-evaluate-expression-because.html

Scenario:
While using RunWithElevatedPrivileges you got following error.

Error : Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack when use new spsite

Solution:
SPSite and SPWeb object should be created inside delegate(), example below. If not you might get the above error.

Wrong Code:

view plaincopy to clipboardprint?
string siteUrl = @”http://localhost“; 
SPSite site = null ;  
SPWeb web = null ; 
SPSecurity.RunWithElevatedPrivileges(delegate() 

    site = new SPSite(siteUrl); 
    web = SPSDestSite.OpenWeb(); 
     
    // To do ( run code here ) 
     
}); 
web.Close(); 
site.Close(); 

string siteUrl = @”http://localhost“;
SPSite site = null ;
SPWeb web = null ;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
    site = new SPSite(siteUrl);
    web = SPSDestSite.OpenWeb();
   
    // To do ( run code here )
   
});
web.Close();
site.Close();Correct Code:view plaincopy to clipboardprint?
string siteUrl = @”http://localhost“; 
SPSecurity.RunWithElevatedPrivileges(delegate() 

     using (SPSite site = new SPSite(siteUrl)) 
     { 
          using (SPWeb web = SPSDestSite.OpenWeb()) 
         { 
              // To do ( run code here ) 
          } 
      } 
}); 

————
export import doc library:
http://www.law.com/jsp/lawtechnologynews/PubArticleLTN.jsp?id=1202443237483
http://www.dev4side.com/community/blog/2010/6/13/sharepoint-api-for-content-migration-and-deployment.aspx
http://vspug.com/dez/2007/11/30/moving-copying-documents-between-libraries-with-metadata-including-version-history/
http://social.msdn.microsoft.com/Forums/en/sharepointserverknowledgenetwork/thread/c5756bc0-75c1-4d84-9f62-3b0e8d5456a5
———-

{“The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.”}

http://ktskumar.wordpress.com/2009/03/09/the-security-validation-for-this-page-is-invalid-click-back-in-your-web-browser-refresh-the-page-and-try-your-operation-again/

———-

http://www.devexpertise.com/2009/02/04/deleting-list-items-in-a-sharepoint-list/
Deleting a item from a sp doc library
Deleting List Items in a SharePoint List
Posted by DevExpert on February 4th, 2009

Occasionally you may encounter a need to delete list items from a SharePoint list.  This sounds like an easy enough task – just loop through the SPList’s Items collection and delete the item.  That would be the intuitive way, but then again this is the SharePoint Object Model.  Let’s take a look a bunch of ways you may try to accomplish this task, and a single way which actually works.

To run these tests, I created a simple custom list named Widgets that contains 10 items:

Incorrect Method #1
The first approach that is probably taken is to loop through the list items with a For..Each loop, and call the Delete() method of each list item, like the following:

using (SPSite siteCollection = new SPSite(“http://server“)) {
    using (SPWeb site = siteCollection.OpenWeb()) {
        SPList list = site.Lists[“Widgets”];

        foreach (SPListItem item in list.Items) {
            item.Delete();
        }
    }
}
However, whenever you run this you encounter the following error:

Collection was modified; enumeration operation may not execute.

To help explain this, it will help to first understand the IEnumerable interface, from with the SPListItemCollection ultimately implements. Unfortunately the MSDN documentation is a little scarce on modifying collections with this interface, but the IEnumerator interface contains a lot of good information that applies to IEnumerable as well. 

Basically, enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection.  An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection (such as deleting), the enumerator is irrecoverably invalidated.
Incorrect Method #2

Ok, learning from the mistake in method 1, it makes sense to eliminate the For..Each loop and use a traditional For loop. This method uses an index which increments at each loop, and we call the Delete(index) method of the list item which accepts an item index:

for (int i = 0; i < list.Items.Count; i++) {
    Console.WriteLine(“Deleting {0}”, list.Items[i].Title);
    list.Items.Delete(i);
}
To visualize the results, I’m outputting the item it’s deleting so we can see if everything is working as it should:

What the heck is happening here?  Why is it deleting every other item?  Well, every time you delete an item from the Items collection, the number of items in that collection decreases and thus the indexes no longer match up.
Incorrect Method #3

Hmm, OK…if it’s deleting every other item because the collection is adjusted when items are deleted from it, let’s just be safe and always try to delete the first item at index 0:

for (int i = 0; i < list.Items.Count; i++) {
    Console.WriteLine(“Deleting {0}”, list.Items[0].Title);
    list.Items.Delete(0);
}
The result is exactly like Method #2 – it deletes every other item:
Incorrect Method #4

For kicks and giggles, what if the code is adjusted to delete the item at index 0 inside a For..Each loop?:

foreach (SPListItem item in list.Items) {
    Console.WriteLine(“Deleting {0}”, list.Items[0].Title);
    list.Items.Delete(0);
}
Woah, that worked! As you can see, it deleted every item:

But wait… What if we need to delete an item only if a condition is met?  Let’s try to loop through the collection and only delete the item whose title is Sample Item #5:

foreach (SPListItem item in list.Items) {
    if (item.Title == “Sample Item 5”) {
        Console.WriteLine(“Deleting {0}”, list.Items[0].Title);
        list.Items.Delete(0);
    }
}
The result is what you should expect after deleting the first item in the index – it deletes the first item, not the item that met the condition:
Correct Method

Ok, finally here’s the correct method for deleting list items.  The trick is to use a decrementing For loop.  The For loop in the following example counts downward (i–) instead of upward (i++), because items are being deleted and the number of items decreases with each increment:

for (int i = list.Items.Count – 1; i >= 0; i–) {
    list.Items.Delete(i);
}
Which produces:

What about deleting an item based on a condition?:

for (int i = list.Items.Count – 1; i >= 0; i–) {
    if (list.Items[i].Title == “Sample Item 5”) {
        Console.WriteLine(“Deleting {0}”, list.Items[i].Title);
        list.Items.Delete(i);
    }
}
It works!:

Hopefully you will always remember to delete list items (actually, the same goes for most other SharePoint collections too, such as SPFieldCollection, SPWebCollection, etc.) using a decrementing counter.  Happy coding!
——————

There are six type of join in SQL 20001) INNER   JOIN2) OUTER   JOIN3) CROSS   JOIN4) EQUI    JOIN5) NATURAL JOIN6) SELF    JOIN

1) INNER JOIN :-

PRODUCESS THE RESULT SET OF MATCHING ROWS                 ONLY FROM THE SPECIFIED TABLES.EXAMPLE—SELECT COLUMN_LIST FROM 1ST_TABLE_NAME JOIN 2ND_TABLE_NAMEON 1ST_TABLE_NAME.MATCING_COLUMN=2ND_TABLE_NAME.MATCING_COLUMN2)

OUTER JOIN :-

DISPLAY ALL THE ROWS FROM THE FIRST TABLE                 AND MATCHING ROWS FROM THE SECOND TABLE.EXAMPLE—SELECT COLUMN_LIST FROM 1ST_TABLE_NAME OUTER JOIN 2ND_TABLE_NAMEON 1ST_TABLE_NAME.MATCING_COLUMN=2ND_TABLE_NAME.MATCING_COLUMN   THERE ARE THREE TYPES OF OUTER JOIN:A)LEFT  OUTER JOIN.B)RIGHT OUTER JOIN.

C)FULL  OUTER JOIN

A)LFET OUTER JOIN :- DISPLAYS ALL THE ROWS FROM THE FIRST                        TABLE AND MATCHING ROWS FROM THE                     SECOND TABLE.EXAMPLE—SELECT COLUMN_LIST FROM 1ST_TABLE_NAME LEFT OUTER JOIN 2ND_TABLE_NAME      ON 1ST_TABLE_NAME.MATCING_COLUMN=2ND_TABLE_NAME.MATCING_COLUMNA)

RIGHT OUTER JOIN :- DISPLAYS ALL THE ROWS FROM THE                        SECOND TABLE AND MATCHING ROWS FROM                         THE FIRST TABLE.EXAMPLE—SELECT COLUMN_LIST FROM 1ST_TABLE_NAME RIGHT OUTER JOIN 2ND_TABLE_NAME        ON 1ST_TABLE_NAME.MATCING_COLUMN=2ND_TABLE_NAME.MATCING_COLUMNA)FULL OUTER JOIN :- DISPLAYS ALL MATCHING AND NONMATCHING                     ROWS  OF BOTH THE TABLES.EXAMPLE—SELECT COLUMN_LIST  FROM 1ST_TABLE_NAME FULL OUTER JOIN 2ND_TABLE_NAME     ON 1ST_TABLE_NAME.MATCING_COLUMN=2ND_TABLE_NAME.MATCING_COLUMN3)

CROSS JOIN :- IN THIS TYPE OF JOIN, EACH ROWS FROM THE                   JOIN WITH EACH ROWS FROM THE SECOND TABLE                WITHOUT ANY CONDTION.                ALSO CALLED AS CARTESIAN PRODUCT.EXAMPLE—SELECT COLUMN_LIST FROM 1ST_TABLE_NAME CROSS JOIN 2ND_TABLE_NAME

4) EQUI JOIN :- DISPLAYS ALL THE MATHCING ROWS FROM JOINED                  TABLE. AND ALSO DISPLAYS REDUNDANT VALUES.                IN THIS WE USE * SIGN TO JOIN THE TABLE.EXAMPLE—SELECT * FROM 1ST_TABLE_NAME JOIN 2ND_TABLE_NAMEON 1ST_TABLE_NAME.MATCING_COLUMN=2ND_TABLE_NAME.MATCING_COLUMN 

5)NATURAL JOIN :- DISPLAYS ALL THE MATHCING ROWS FROM                       JOINED  TABLE.IT RESTRICT                                REDUNDANT VALUES.6)SELF JOIN :- IN THIS TABLE JOIN WITH ITSELF WITH                 DIFFERENT ALIAS NAME. ASSUME DEPARTMENT IS A TABLE:SELECT A.DEP_NAME,B.MANAGER_ID(COLUMN LIST) FROM DEPARTMENT A JOIN DEPARTMENT BON A.MANAGER_ID=B.MANAGER_ID
——————-
1…What are the default databases that comes with SP.?
Portalname_SITE
Portalname_PROF
Portalname_SERV
 and a config db..

2… How to make two  webparts communicate?
If it is ur custom web part then the code has to implement ICellConsumer,ICellProvider /  IRowConsumer,IRowProvider etc interfaces.

If it is SP provided web parts then u have the options enabled if the web parts are eligible to be connected

3.  How many ways can a webpart be created?
like asp.net webpart,,,,sharepoint provided webpart
There r only 2 basic distinction

1. WP provided by SP.
2. Custom WP created by you.

4..where these webparts are created …Is it in Asp.net or ..

where these methods CreateChild,RenderChild,.,,,comes into picture

U can create WP using any .Net lang….The methods listed are used to create controls necessary for display (Create….) ….and render it  into HTML tags (Render….)…

5..How to get the details from database to populate a treeview webpart???

I haven’t done any thing of that sort….if u rn’t very keen on db u can even choose SPObject model

what r the tools that are present in sharepoint toolbox?
Forms Authentication:
http://weblog.vb-tech.com/nick/archive/2006/06/14/1617.aspx

Overall Features:
http://office.microsoft.com/en-us/sharepointserver/default.aspx
http://www.readify.net/uncovering+sharepoint+2007.aspx
Reports Center:

http://www.microsoft.com/technet/community/events/moss2007/dsk-100.mspx
http://technet2.microsoft.com/Office/en-us/library/fbe7fe46-8d60-4de2-a699-7921c13dbdc91033.mspx?mfr=true
KPIs:

http://office.microsoft.com/en-us/sharepointserver/HA100800271033.aspx?pid=CH101785431033

http://management.about.com/cs/generalmanagement/a/keyperfindic.htm
http://jopx.blogspot.com/2006/08/report-center-and-kpis-in-moss-2007.html
http://blogs.3sharp.com/Blog/davidg/archive/2006/07/05/1529.aspx

MySite:

http://office.microsoft.com/en-us/sharepointserver/CH100964111033.aspx

http://office.microsoft.com/search/redir.aspx?assetid=CH100964111033&QueryID=hsOAGEQTn0&respos=24&rt=2

BI Features:

http://office.microsoft.com/en-us/sharepointserver/HA100872181033.aspx
Screen Casts:

http://betterecm.wordpress.com/2006/10/25/moss-2007-videos-screencasts/
http://betterecm.wordpress.com/sharepoint-2007-stuff/

RSS Feeds:

http://office.microsoft.com/en-us/sharepointserver/HA100214251033.aspx
Blogs:

http://office.microsoft.com/en-us/sharepointserver/CH101788371033.aspx
WorkFlows:

http://office.microsoft.com/en-us/sharepointserver/CH101782961033.aspx
http://office.microsoft.com/en-us/sharepointserver/CH101248821033.aspx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: