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 9168421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:37:19+00:00 2026-06-17T15:37:19+00:00

I’m using local database to store my data in Windows Phone 8 application. At

  • 0

I’m using local database to store my data in Windows Phone 8 application. At first I have data stored in JSON object which is converted to my classes objects and then collection of these objects I try to store in local database. I was checking in debug mode and data is in those objects, but when I check database, it’s empty.

This is how I move data from collection to database:

// Data context for the local database
private TablesDataContext tablesDB;

// Define the query to gather all of items.
var customersTablesInDB = from CustomerItem todo in tablesDB.CustomersTable
                                select todo;

// Execute the query and place the results into a collection.
CustomersTable = new ObservableCollection<CustomerItem>(customersTablesInDB);

foreach (Customer customer in customersList) 
{
    // Create a new item
    CustomerItem newCustomer = new CustomerItem 
    { 
        Id = customer.id,
        Number = customer.number.Value,
        Name = customer.name,
        Email = customer.email
    };

    // Add item to the observable collection.
    CustomersTable.Add(newCustomer);

    // Add item to the local database.
    tablesDB.CustomersTable.InsertOnSubmit(newCustomer);   
}

Here is my class for DataContext:

public class TablesDataContext : DataContext
{
    // Specify the connection string as a static, used in main page and app.xaml.
    public static string DBConnectionString = "Data Source=isostore:/Customers.sdf";

    // Pass the connection string to the base class.
    public TablesDataContext(string connectionString)
        : base(connectionString)
    { }

    // Specify a single table for the items.
    public Table<CustomerItem> CustomersTable;
}

And here is my CustomerItem class:

[Table]
public class CustomerItem : INotifyPropertyChanged, INotifyPropertyChanging
{
    // Define ID: private field, public property and database column.
    private int _id;

    [Column(IsPrimaryKey = true, IsDbGenerated = false, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
    public int Id
    {
        get
        {
            return _id;
        }
        set
        {
            if (_id != value)
            {
                NotifyPropertyChanging("Id");
                _id = value;
                NotifyPropertyChanged("Id");
            }
        }
    }

    // Define item name: private field, public property and database column.
    private int? _number;

    [Column]
    public int? Number
    {
        get
        {
            return _number;
        }
        set
        {
            if (_number != value)
            {
                NotifyPropertyChanging("Number");
                _number = value;
                NotifyPropertyChanged("Number");
            }
        }
    }

    // Define completion value: private field, public property and database column.
    private String _name;

    [Column]
    public String Name
    {
        get
        {
            return _name;
        }
        set
        {
            if (_name != value)
            {
                NotifyPropertyChanging("Name");
                name = value;
                NotifyPropertyChanged("Name");
            }
        }
    }

    // Define completion value: private field, public property and database column.
    private String _email;

    [Column]
    public String Email
    {
        get
        {
            return _email;
        }
        set
        {
            if (_email != value)
            {
                NotifyPropertyChanging("Email");
                _email = value;
                NotifyPropertyChanged("Email");
            }
        }
    }


    // Version column aids update performance.
    [Column(IsVersion = true)]
    private Binary _version;

    #region INotifyPropertyChanged Members

    public event PropertyChangedEventHandler PropertyChanged;

    // Used to notify the page that a data context property changed
    private void NotifyPropertyChanged(String propertyName)
    {
        if (PropertyChanged != null)
        {
           PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    #endregion

    #region INotifyPropertyChanging Members

    public event PropertyChangingEventHandler PropertyChanging;

    // Used to notify the data context that a data context property is about to change
    private void NotifyPropertyChanging(String propertyName)
    {
        if (PropertyChanging != null)
        {
            PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
        }
    }

    #endregion

}
  • 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-17T15:37:20+00:00Added an answer on June 17, 2026 at 3:37 pm

    You are missing a “tablesDB.SubmitChanges()” after your foreach-loop.

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

Sidebar

Related Questions

I am using jsonparser to parse data and images obtained from json response. When
I am using JSon response to parse title,date content and thumbnail images and place
We're building an app, our first using Rails 3, and we're having to build
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I have a view passing on information from a database: def serve_article(request, id): served_article
I'm making a simple page using Google Maps API 3. My first. One marker

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.