I have a site using ASP.NET membership. I also have an excel file with about 60 user records. How can I import the records into the membership database, without having to
foreach (record in recordset) {
if (!(Roles.RoleExists(record["Role"])) {
Roles.CreateRole(record["Role"]);
}
if (Membership.GetUser(record["Username"]) == null) {
System.Web.Security.MembershipCreateStatus status;
Membership.CreateUser(record["Username"], record["Password"], record["Email"], record["RSecurityQuestion"], record["SecurityAnswer"], true, status);
if (status == System.Web.Security.MembershipCreateStatus.Success) {
Roles.AddUserToRole(record["Username"], record["Role"]);
}
}
}
I can't recall the code to create a recordset from an Excel file off the top of my head.
EDIT: Here is a good post on how to read/write excel files with ADO.NET