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

  • SEARCH
  • Home
  • 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 6706607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:32:26+00:00 2026-05-26T07:32:26+00:00

My issue seems to be the same as this post and this post but

  • 0

My issue seems to be the same as this post and this post but neither seem to apply to my situation.

I have an entity defined as the following (modified to show columns and definitions only):

public partial class Payee
{
    [Column(Storage = "_PayeeId", IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false)]
    public int PayeeId { get; set; }

    [Column(Storage = "_PayeeName", DbType = "NVarChar(20)", CanBeNull = false)]
    public string PayeeName { get; set; }

    [Column(Storage = "_Active")]
    public System.Nullable<bool> Active

    [Column(IsVersion = true)]
    private Binary _version;

    [Association(Storage = "_Transactions", ThisKey = "PayeeId", OtherKey = "PayeeId")]
    public EntitySet<Transaction> Transactions { get; set; }
}

From App.xaml.cs, when the app initially starts, I am loading some sample data into the database:

Payee pay1 = new Payee { PayeeName = "My Bank" };
App.ViewModel.SavePayee(pay1);

And the SavePayee method is as follows:

public void SavePayee(Payee payee)
{
    Datacontext.Payees.InsertOnSubmit(payee);
    Datacontext.SubmitChanges();
}

This works fine when I create my ‘sample data’ when it is called from App.xaml.cs. Now, when I try to create a new Payee later on in the application (txtPayee.Text DOES have a value):

Payee payee = txtPayee.SelectedItem as Payee;
if (payee == null)
{
    payee = new Payee { PayeeName = txtPayee.Text };
    App.ViewModel.SavePayee(payee);
}

I’m given the error: An overflow occurred while converting to datetime.

What could be causing this error?

  • 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-05-26T07:32:27+00:00Added an answer on May 26, 2026 at 7:32 am

    Turns out, in this case, the error message was SPOT ON. Here’s how I found my error. Hopefully it helps others in the future:

    My entity was being inserted without issue, and actually, the error message was correct. How did I figure out what was going on? I wrapped the contents of my save method with this code:

    System.IO.IsolatedStorage.IsolatedStorageFile iso = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); 
    using (checkbookDB.Log = new System.IO.StreamWriter(iso.CreateFile("log.txt"))) 
    { 
    }
    

    So when an error would occur in that method, it would write out the results to the text file. After I got the error message, I downloaded the file from the emulator using the IsolatedStorageExplorerTool that came with the WP7 SDK. What did I find in the text file?

    -- CURSOR BASED INSERT [Payees] 
    -- [PayeeName] <= [test payee] 
    -- [Active] <= [] 
    
    -- AUTOSYNC [_version] <= [System.Byte[]] 
    -- AUTOSYNC [PayeeId] <= [13] 
    -- CURSOR BASED INSERT [Transactions] 
    -- [TransDate] <= [1/1/0001 12:00:00 AM]
    -- [TransAmount] <= [0] 
    -- [TransType] <= [0] 
    -- [RefNum] <= [] 
    -- [Memo] <= [] 
    -- [PayeeId] <= [0] 
    -- [CategoryId] <= [] 
    -- [AccountId] <= [1] 
    -- [Cleared] <= [False] 
    

    Hmm….Ok…Looks like my Payee is inserting properly, and I even have a new PayeeId. But wait…Transaction? Why is there a transaction trying to insert?

    Welp: I’m a noob to MVVM. I’ve been working with it off-hours for the last month and a half, so I’m not familiar with best practices. On my ViewModel, I created a public entity, named account. I used this variable to track the selected account in the application so the correct data is displayed all over the place. In my page that I was attempting to save a new Payee from, when the page is created, I create an instance of a Transaction entity to map data to/from controls on the screen. Well what I was doing, in my OnNavigatedTo method, was setting

    transaction.Account = App.ViewModel.account 
    

    So when I would go to save the transaction, I knew which account to save it to. Well what this was really doing (I think), was telling my datacontext that Hey! I have this transaction entity that I am changing by adding an account to it. So when I would enter the datacontext.SaveChanges method, it tried to save an empty, BLANK transaction entity.

    Why was this line way up in the OnNavigatedTo? I’m not sure. I moved it down to the Save method, where it belongs.

    /doh

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

Sidebar

Related Questions

This seems like an easy enough issue but I can't seem to find the
I have an issue that seems like very flaky behavour, is this a problem
This seems like it would be a common issue to be but I don't
I've seen several threads with the same issue, but none of the solutions seems
I have a problem that seems very related to that in another post, but
I have a weird issue that only seems to be affecting IE 7. The
I've been investigating this issue that only seems to get worse the more I
There seems to be an issue simulating the backspace key with java.awt.Robot . This
This seems to me to be the kind of issue that would crop up
It seems (at least that is our understanding of the issue at this point)

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.