Copy table contents from one table to another

Posted by Community Admin on 04-Aug-2018 11:07

Copy table contents from one table to another

All Replies

Posted by Community Admin on 25-Sep-2013 00:00

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.

Posted by Community Admin on 30-Sep-2013 00:00

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();
For a more detailed explanation on using Sitefinity API, please refer to our Documentation. Regards,
Ivan D. Dimitrov
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed