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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:34:18+00:00 2026-05-23T03:34:18+00:00

I have a local Microsoft SQL Server Compact 3.5 database (.sdf) in my WPF

  • 0

I have a local Microsoft SQL Server Compact 3.5 database (.sdf) in my WPF program.

In my datagrid, I see “old” data. Only if I click refresh in the Database Explorer in Visual Studio 2010, do I see the new inserted data.

How can you programmatically refresh the database connection?

To be clear:

On the load of my programm I put in data to the database with an SQL query like INSERT INTO clients VALUE (2, Peter, Smith)
Then I call een an tableAdapter.Fill(dataset.clients) and this.DataContext = dataset.clients.DefaultView;

I expect the dataTable in the dataSet will be filled with data which I inserted a second ago in the database. And after that the data is shows in the dataGrid. But that don’t happen. I only see the inserted data if I stop debugging and press (in design-time) the refresh button of the Database Explorer en then debug again…

  • 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-23T03:34:18+00:00Added an answer on May 23, 2026 at 3:34 am

    If you’re trying to bind from your SQL CE database, consider implementing code that uses data binding. This will ensure your data is always ‘fresh’ on your grid. Here’s some sample code on Data Binding in WPF.

    SqlConnection con = new SqlConnection();
    SqlDataAdapter ad = new SqlDataAdapter();
    SqlCommand cmd = new SqlCommand();
    String str = "SELECT EmployeeID, FirstName, LastName, BirthDate, City, Country FROM Employees";
    cmd.CommandText = str;
    ad.SelectCommand = cmd;
    con.ConnectionString = "Data Source=MyData.sdf;Persist Security Info=False";
    cmd.Connection = con;
    DataSet ds = new DataSet();
    ad.Fill(ds);
    ListViewEmployeeDetails.DataContext = ds.Tables[0].DefaultView;
    con.Close();
    
    ....
    
    <Grid x:Name="Grid1">
      <ListView Name="ListViewEmployeeDetails" Margin="4,20,40,100" ItemTemplate="{DynamicResource EmployeeTemplate}" ItemsSource="{Binding Path=Table}">
        <ListView.View>         
          <GridView>
            <GridViewColumn Header="Employee ID" DisplayMemberBinding="{Binding Path=EmployeeID}"/>
            <GridViewColumn Header="First Name" DisplayMemberBinding="{Binding Path=FirstName}"/>
            <GridViewColumn Header="Last Name" DisplayMemberBinding="{Binding Path=LastName}"/>
            <GridViewColumn Header="BirthDate" DisplayMemberBinding="{Binding Path=BirthDate}"/>
            <GridViewColumn Header="City" DisplayMemberBinding="{Binding Path=City}"/>
            <GridViewColumn Header="Country" DisplayMemberBinding="{Binding Path=Country}"/>
          </GridView>
        </ListView.View>
      </ListView>
    </Grid>
    

    It sounds as if you’re expecting to see ‘fresh’ data in your grid at design-time. “click refresh in Database Explorer” suggests that the design surface you’re viewing.

    If not, then your statements around Database Explorer and anything at run-time don’t make sense. Your grid should be repopulated/databound on an event that makes sense (form load, user clicking button, user inserting a row). The user doesn’t/shouldn’t know about Database Explorer. The proper way to have your grid show the latest data is myGrid.DataBind();

    If so, may I suggest that it shouldn’t/doesn’t really matter, as the data shown on the grid is simply intended to be a ‘placeholder’. If you did want to see fresh data, then your only option is as you suggest: ‘refreshing’ via Database Explorer.

    It’s very unclear on what you’re seeing or expecting. Suggest editing your question with your code, and some screenshots to illustrate.

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

Sidebar

Related Questions

I have a website using Microsoft SQL 2008 server over local network. Sometimes, SQL
I have a local database with some data of type geography in it. I
I have a WPF application which uses a (currently) local database to act as
I try to use SQL Server Compact Edition with Entity Framework in Visual Studio
We have an application that will be collecting data and storing it in local
I have a server where I use Microsoft CRM. MS CRM auto-generate web references.
I have an ASP.NET 3.5 app with a SQL 2005 Express .mdf database file
I was trying to create a backup for my SQL Server Database using SQL
I am working on WPF application, and now I have to choose which database
I have a SQL Server 2005 named instance using Windows Authentication with domain groups

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.