I've one table in SQL Server that consists of datetime posts. I personally use LINQ to SQL.

While running this program all information is held in a table and that i get all of the results correctly.

But the moment I close the run, there's no data within the table and also the getall function returns null.

I am unable to discover the problem.

The code to place data right into a table is:

public bool AddTime(WorkTime ToAdd)
{
    try
    {
        _context.WorkTimes.InsertOnSubmit(ToAdd);
        _context.SubmitChanges();
    }
    catch (Exception)
    {
        return false;
    }
    return true;
}

Probably, you utilizing a SQL Server Express Edition stand alone file, that's getting re-used (replicated towards the output folder) any time you build.

Options:

  • register a database within the engine itself, instead of utilizing a stand alone file, or
  • try not to overwrite your database whenever you build