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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:39:19+00:00 2026-06-03T15:39:19+00:00

i am trying to update a user table with a single value update, but

  • 0

i am trying to update a user table with a single value update, but i can’t figure out what i’m doing wrong. this is what i have:

public static void ApplyROB(string  ROBread, string userName)
        {
            using (SERTEntities ctx = CommonSERT.GetSERTContext())
            {
                    // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
                    // Audit of the transfer
                datUser trUser = new datUserRole();
                trUser.ROB = ROBread;
                trUser.AccountName = userName;
                // Persist update to DB
                ctx.SaveChanges();

            }
        }

am i way off? nothing happens when i click on the update.
how do i say, where username = username? did i do it right?

basically in need a simple:

update datUser set ROB = "Y" where AccountName= "myusername"

it’s turning out to be a bit more complicated in LINQ using Context

please help.

  • 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-03T15:39:21+00:00Added an answer on June 3, 2026 at 3:39 pm

    You’re not adding your new entity to the context, thus when you save, the context is unaware of any changes. You need something like…

    ctx.datUserRoles.Add(datUserRole)
    

    To do an update, you need to retreive an entity from the context, make changes to it, then save… so:

    var entity=ctx.datUserRoles.SingleOrDefault(dur=>dur.AccountName==someUserName);
    if(entity!=null)
    {
        entity.someProp=someVal;
        ctx.SaveChanges();
    }
    else
    {
        throw new UnexpectedOperationException(); //or however you want to fail
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was looking at a schema and trying to figure out what this table
I'm trying to UPDATE a column for a user, so that they can only
I'm trying to update single attribute of a user model from a admin controller
I have a User model. I am trying to update a confirm attribute from
I am using Linq2Sql and trying to update a table. But no update happens
Assuming that I have objects similar to this: public class User { public int
i have a table ---------- User ---------- userID(pk) startdate // update : i am
I have a table user_has_alerts (userID, alertID, dateAlerted) and i'm trying to update all
I am trying to make a simple web app. I have a User table
Trying to do this with a single query, but want to get a list

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.