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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:56:38+00:00 2026-06-17T13:56:38+00:00

I am completely stumped on this issue. I have been searching for a while

  • 0

I am completely stumped on this issue. I have been searching for a while now and still have no answer for how to solve the problem.

I run a query in which I attempt to set the value on. The problem is that they come up as read only variables if I do not specify Select New With. When I specify Select New With it doesn’t update the database. Some of the code is listed below.

My goal is to allow the shooter to update the DataGridView which would update the database. I was told in another question on StackOverflow that the DataGridView would not update the database simply by the user inputting data. So I created a update button which runs the code listed below.

Code:

Query using Select New With allows me to edit variables but won’t commit to database:

Dim query = From t In db.Trophies _
            Select New With {t.TrophyName, t.WinnerId, t.Name, t.Score, t.Printed}

Query won’t let me edit variables. Error message reads “Property ‘TrophyName’ is ‘ReadOnly’:

Dim query = From t In db.Trophies _
            Select t.TrophyName, t.WinnerId, t.Name, t.Score, t.Printed

Code where I want to update the results:

Dim i as integer = 0
For Each result In query
    result.WinnerId = dgvTrophies.Rows(i).Cells(dgvTrophies.Columns("WinnerId").Index).Value
    result.Name = dgvTrophies.Rows(i).Cells(dgvTrophies.Columns("Name").Index).Value
    result.Score = dgvTrophies.Rows(i).Cells(dgvTrophies.Columns("Score").Index).Value
    db.SubmitChanges()
    i += 1
Next

Table:

PRIMARY KEY TrophyId int auto-increments
TrophyName varchar(50)
WinnerId char(7) Allow Nulls
Name varchar(20) Allow Nulls
Score int Allow Nulls
Printed bit

Any advice or answers would be greatly appreciated.

EDIT: I’ve tried setting ObjectTrackingEnabled to True but it didn’t solve the issue.

EDIT: To get it to do a more “automatic” update, after the user leaves edit mode on the DataGridView I call db.SubmitChanges which updates the database and no longer requires an update button.

  • 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-17T13:56:39+00:00Added an answer on June 17, 2026 at 1:56 pm

    Using Select new with { ... creates an anonymous object, and changes to that is not submited to the database. You need to work with the linq entities. For Example:

    Dim query = From t In db.Trophies _
                Select t
    

    Or simply

    Dim query = db.Trophies
    

    That will work.

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

Sidebar

Related Questions

I've been staring at this one for a while and I'm completely stumped. You'll
I have to admit I am COMPLETELY stumped on this one. I've been scouring
I have NEVER had this problem before and i am completely stumped. the site
I'm working on a school assignment and I've been completely stumped with this step.
I am completely stumped at the nature of this problem. We export data from
I am completely stumped with how to use .htaccess and I have an issue
I am completely stumped on this problem and it should be so simple that
Okay, so I've been completely stumped by this compiler error for hours, and the
I'm completely stumped. I have no clue why this isn't working and it seems
I have been looking everywhere on here and Google, but I still have this

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.