Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8561345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:28:56+00:00 2026-06-11T16:28:56+00:00

I am using the following code to update clock in and clock out times

  • 0

I am using the following code to update clock in and clock out times in the record table but it doesn’t save the data to the database. I checked the mdf file with sql management studio and there is no data saved. What am I doing wrong?

private void btClockIn_Click(object sender, EventArgs e)
    {
        using (TimeKeepEntities ctx = new TimeKeepEntities())
        {
          // if employee clocked out add new clock in record else update existing record with clock out time
            if (cmbProjects.Enabled)
            {
                tblTimeRecord record = new tblTimeRecord();
                record.RecordID = DateTime.Now; 
                record.EmployeeID = (int)cmbEmployees.SelectedValue;
                record.ProjectID = (int)cmbProjects.SelectedValue;
                record.ClockIn = DateTime.Now;


                ctx.tblTimeRecords.Add(record);
                ctx.SaveChanges();

                update_cmbProjects_btClockIn();

            }
            else
            {
                tblTimeRecord record = (from r in ctx.tblTimeRecords
                                        where r.EmployeeID == (int)cmbEmployees.SelectedValue && !r.ClockOut.HasValue
                                        select r).FirstOrDefault();
                record.ClockOut = DateTime.Now;
                ctx.SaveChanges();

                update_cmbProjects_btClockIn();
            }
        }
    }

EDIT 1: Here is my app.config file (including what looks like a connection string)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <connectionStrings>
    <add name="TimeKeepEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\TimeKeep.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
</configuration>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:28:58+00:00Added an answer on June 11, 2026 at 4:28 pm

    As MM suggested in the comments, I also suspect that you’re looking at the wrong MDF file the first time. With SQL Express those wizards tend to make copies of it and the final copy that the application is using is sometimes a different location than the one created by the wizard. The final one that is used is usually in the App_Data folder of your solution but you can trace in Debug in the save changes to be sure.

    Here is an answer to a similar problem: Entity Framework 4.1 is not adding any rows to SQL Server Express database

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code to update a record. Bad thing is that it's
I am using the following code to update my mysql table where both moving50
I am currently using the following code to update form data before submission. $('.countyx').change(function(){
I'm using the following code to update a DataGridView's cell value. This is called
I'm using the following code to UPDATE certain records from the db: IList<Item> list;
Im using the following code to attempt to update several static cells in my
I am using following steps to update code on server after login to server:
I am using the following code to invoke the http://www.highoncoding.com/Customers.asmx web service. UPDATE 1:
Im using the following ajax code to submit data from a form to a
I'm using the following snippit of code to update an entry: Protected Sub Button2_Click(ByVal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.