Copy table contents from one table to another
Hello,
I have created a table in sitefinity database named abc. I want to copy all the rows/ records of from abc table to default sitefinity table named sf_users. How can i perform this operation ?
In abc table, i have many columns like 50 columns fields, i will manage that fields in both table, but i need to know how i can transfer data from abc to Sf_users, and Sf_sitefinity_profiles ?
Regards.
Hi,
You cannot copy the contents of a custom made table to Sitefinity tables freely via SQL statements. This will cause many problems considering ID, inheritance, hierarchy, sequence and restrictions. If you want to make changes by adding/removing/modifying users and user profiles you have to do so from the API. This will generate all of the entries listed above automatically while you only enter the needed data - name, email etc. The following sample shows how to create a user with administrative role through the API:
var userManager = UserManager.GetManager("Provider - Defualt or Ldap"); System.Web.Security.MembershipCreateStatus status; userManager.Provider.SuppressSecurityChecks = true; var user = userManager.CreateUser("Username", "Password", "Email@test.com", "SecretQuestion", "SecretAnswer", true, null, out status); userManager.SaveChanges(); RoleManager roleManager = RoleManager.GetManager("AppRoles"); roleManager.Provider.SuppressSecurityChecks = true; var role = roleManager.GetRole("Role you want to assign"); roleManager.AddUserToRole(user, role); roleManager.SaveChanges();