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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:58:59+00:00 2026-05-29T10:58:59+00:00

I have a list view with two colums in wpf Customername and Isvalid.I am

  • 0

I have a list view with two colums in wpf Customername and Isvalid.I am using linq to sql to get the data from my sql table.when i am trying to update a value to the table i dont see any changes to the table.

Here is my code when i click on the save button:

 try
        {
            CustomersDataContext dataContext = new CustomersDataContext();
            Customer customerRow = MyDataGrid.SelectedItem as Customer;
            string m = customerRow.CustomerName;
            Customer customer = (from p in dataContext.Customers
                                 where p.CustomerName == customerRow.CustomerName
                                 select p).Single();

            customer.Isvalid=false;

            dataContext.SubmitChanges();
            MessageBox.Show("Row Updated Successfully.");

        }
        catch (Exception Ex)
        {
            MessageBox.Show(Ex.Message);
            return;
        }

I can see that i am able to query the record based on the customername selected but the value is not updating.

I would be glad if some one can point out where am i missing the logic to update the “ISVALID” value to the data base.

  • 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-29T10:59:00+00:00Added an answer on May 29, 2026 at 10:59 am

    Firstly, where’s your using(get_datacontext){...} block? You need to dispose of DataContexts when you are done with them!

    Anyway…

    My guess is that the update statement is generating a where clause that’s far too tight, or just plain wrong.

    I would be checking the ‘Update Check’ property of each of the columns in your mapped table in the Linq to Sql designer. The simplest thing to do is to set the primary key column to Always and set all the others to Never. You can also consider setting them to WhenChanged.

    The designer’s default behaviour is generally to set it to Always for everything; not only does this cause horrible WHERE clauses for updates, but can occasionally also cause problems. Obviously such behaviour is required for proper concurrency checking (i.e. two threads updating the same row); so be aware of that.

    Oh, thinking of something else – you can also get this behaviour if your table doesn’t have a primary key designated in the designer – make sure one of the columns is.

    Finally you can check the SQL being generated when SubmitChanges is called; by attaching a TextWriter to the DataContext.Log property; or equally IntelliTrace in VS2010 will collect all ADO.Net queries that are run if you start with debugging. This is invaluable in debugging why L2S stuff isn’t working as expected.

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

Sidebar

Related Questions

I am using LINQ to Entites where I have two table objects ( ReferenceCodes
tl;dr: I need to show data from two different tables in the list view
I have a list view filled with data. I set up a context menu
I currently have a list view which has several rows of data and I
i have two mehods, one to collect SQL data and one to put it
I have a custom control that is derived from ListView . This list view
I need to present my table view with a two column list. I read
I have a listview with two columns and I'm using a context menu to
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I have a list view control which at the moment only allows one item

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.