More in this section

Forums / Developing with Sitefinity / Copy table contents from one table to another

Copy table contents from one table to another

2 posts, 0 answered
  1. Srk
    Srk avatar
    13 posts
    28 Feb 2012
    25 Sep 2013
    Link to this post
    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 ?
  2. Ivan D. Dimitrov
    Ivan D. Dimitrov avatar
    310 posts
    26 Mar 2015
    30 Sep 2013
    Link to this post

     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", "", "SecretQuestion", "SecretAnswer", true, null, out status);
               RoleManager roleManager = RoleManager.GetManager("AppRoles");
               roleManager.Provider.SuppressSecurityChecks = true;
               var role = roleManager.GetRole("Role you want to assign");
               roleManager.AddUserToRole(user, role);
    For a more detailed explanation on using Sitefinity API, please refer to our Documentation. Regards,
    Ivan D. Dimitrov
    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
2 posts, 0 answered