Search code examples
c#asp.netsqlasp.net-membershipprofiles

ASP.NET Profiles - Add a profile to an existing user


How do you add a profile entry (consisting of a guid, two strings, and an integer) to an existing user in the default SQL profile and membership providers? I can do this either via a sql query or C# code.

I need to add a bunch of these profiles to already existing users.


Solution

  • You can use various methods of ProfileBase:

    var profile = ProfileBase.Create(username);
    profile.SetPropertyValue("MyGuid", aGuid);
    profile.SetPropertyValue("MyString", aString);
    // etc
    profile.Save()