Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SDK sample code error

Status
Not open for further replies.

sheila11

Programmer
Dec 27, 2000
251
0
0
US
Hi all,

I have Sharepoint 2003. I downloaded the WSS SDK and tried to run the first example code in my asp.net app.:

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Utilities;

SPSite mySite = SPControl.GetContextSite(Context);
SPWebCollection allSites = mySite.AllWebs;
foreach (SPWeb subSite in allSites)
{
string listGroups = "";
SPUserCollection allUsers = subSite.Users;
foreach (SPUser user in allUsers)
{
if (user.LoginName == TextBox1.Text)
{
SPRoleCollection allGroups = user.Roles;
foreach (SPRole group in allGroups)
{
listGroups += SPEncode.HtmlEncode(group.Name) + " ";
}
userList += subSite.ServerRelativeUrl.ToString() + "<BR>";
}
}
}

I get error in the "foreach" statement, when the debugger steps to the "allSites" word.
The error is: "Input string was not in a correct format".

I have set reference to Microsoft.Sharepoint.DLL & am using .Net 2.0.

What could be going wrong ? Any pointers ?

TIA,
Sheila

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top