0
votes

I would like to create a console agent to retrieve all SharePoint 2013 FBA user that I have setup. Using the code below:

MembershipUserCollection uColl = System.Web.Security.Membership.GetAllUsers();
foreach (MembershipUser u in uColl)
{
    Console.WriteLine(u.UserName);
}

The console returns error:

Unhandled Exception: System.Web.HttpException: Unable to connect to SQL server database.

I think the problem is I didn't not setup my Connection String to SQL before execute the code? How to setup the connection then? Sorry I am new to this.

1

1 Answers

1
votes

You should have your connection string and membership provider which is in web.config of your web application, in you app.config of your console application. That way, your app will find the correct parameters to make a database connection