locked
What am I missing? RRS feed

  • Question

  •  

    Hello everyone ...

     

    I am trying to learn more about Linq and I am stuck a little. Here is my code :

     

    private AppUser CreateUser()

    {

    AppUser NewUser = new AppUser();

    NewUser.Alias = (creationWizard.FindControl("txtAlias") as TextBox).Text.ToLower().Trim();

    NewUser.Name = (creationWizard.FindControl("txtPrenume") as TextBox).Text.Trim();

     

    return NewUser;

    }

     

    protected void creationWizard_FinishButtonClick(object sender, WizardNavigationEventArgs e)

    {

    MyuDataContext context = new MyuDataContext(Utils.MyuConnectionString);

    AppUser NewUser = CreateUser();

    try

    {

    context.SubmitChanges();

    }

    catch (ProviderException pEx)

    {

    Response.Write(pEx.Message);

    }

    // Detect concurrency conflicts.

    catch (ChangeConflictException)

    {

    // Resolve conflicts.

    context.ChangeConflicts.ResolveAll(RefreshMode.KeepChanges);

    }

    catch (Exception ex)

    {

    Response.Write(ex.Message + " <br />" + status.ToString());

    }

    }

     

     

    This code does not trow any exception, but it does not save my context either. I am using vs2008 beta 2, I am sure is something trivial and I'm gone appreciate any and all help on this.

     

    Thanks a lot,

     

    Calin

    Saturday, January 26, 2008 11:26 PM

Answers

  • You need to tell the DataContext about you new object.

     

    context.AppUsers.InsertOnSubmit(NewUser);

     

     

     

    Sunday, January 27, 2008 1:13 AM