locked
Data Context when saving data it is being mangled RRS feed

  • Question

  • User1983259352 posted

    I am using linqtosql framework 3.5  for data access and have moved the connection into its own static class.  What I am seeing when there are multiple users the data gets mangled meaning one persons data gets mixed with another users.  I believe this has something to do with the way I am handling connections I have the following code.

    This code is in a class file that is referenced by the web forms application

    /////////////////////////////  

    public static class Configuration
    {
    public static MyLinq2SQLDataContext db = new MyLinq2SQLDataContext(myConnectionString);

    //=================================================================
    /// <summary>
    /// Returns the connection string
    /// </summary>
    //=================================================================
    public static String myConnectionString
    {
    get
    {
    return @"Data Source=  "someconnection";
    }
    }

    This is a example of a button  clicked event in webforms.

    //=================================================================
    /// <summary>
    /// btnAddCertificationsSave_Click
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    //=================================================================
    protected void btnAddCertificationsSave_Click(object sender, EventArgs e)
    {
    if (Page.IsValid)
    {
    int certificationId = Convert.ToInt32(ddlCertifications.SelectedValue);
    long memberId = EnterpriseDB.Person.GetMemberId(SelectedInstructorId);
    DateTime expirationDate = Convert.ToDateTime(txtAddExpirationDate.Text);
    DateTime certificationDate = Convert.ToDateTime(txtAddCertificationDate.Text);
    CertificationWithVersion versionMatch = GetCertificationWithVersionList.Where(v => v.CertificationId == certificationId).SingleOrDefault();

    MemberCertification memberCert = new MemberCertification()
    {
    CertificationId = certificationId,
    CertifiedDate = certificationDate,
    ExpirationDate = expirationDate,
    IsAdvanced = false,
    IsRecertification = false,
    IsOmega = false,
    MemberId = memberId,
    OverrideDynamicRequirements = false,
    SystemId = 1,
    VersionId = versionMatch.VersionId,
    };


    Configuration.db.MemberCertifications.InsertOnSubmit(memberCert);
    Configuration.db.SubmitChanges();

    }

    Monday, August 31, 2015 7:25 PM

All replies