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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:11:59+00:00 2026-06-17T09:11:59+00:00

I’m developing a website as a school project using Microsoft Visual Web Developer and

  • 0

I’m developing a website as a school project using Microsoft Visual Web Developer and C# based-ASP.Net.

I have implemented a simple class to represent a User as it is formed in a db. The class
Has members that represent the columns in the db, and a couple of static methods to create an instance from a DataTable result. The following code is used (MyDbase is some help class we were given):

//User.cs, placed in A
using System;

public class User
{
    private int id;
    private String email;
    private String firstName;
    private String lastName;
    private String username;
    private String passwd;
    private String birthDate;
    private bool isMale;
    private String phone;
    private String avatarUrl;
    private bool isAdmin;

    ... //Accessors and mutators

    public User( int _id, String _email, String _firstName, String _lastName, String _username, String _passwd,
                String _birthDate, bool _isMale, String _phone, String _avatarUrl, bool _isAdmin )
    {
        this.id = _id;
        this.email = _email;
        this.firstName = _firstName;
        this.lastName = _lastName;
        this.username = _username;
        this.passwd = _passwd;
        this.birthDate = _birthDate;
        this.isMale = _isMale;
        this.phone = _phone;
        this.avatarUrl = _avatarUrl;
        this.isAdmin = _isAdmin;
    }

    public static User getUserForSqlResult(System.Data.DataTable result)
    {
        User newUser = null;
        if (result.Rows.Count == 1)
        {
            newUser = new User((int)result.Rows[0]["id"], (String)result.Rows[0]["email"], 
                                (String)result.Rows[0]["firstName"], (String)result.Rows[0]["lastName"], (String)result.Rows[0]["username"],
                                (String)result.Rows[0]["passwd"], (String)result.Rows[0]["birthDate"], (bool)result.Rows[0]["isMale"],
                                (String)result.Rows[0]["phone"], (String)result.Rows[0]["avatarUrl"], (bool)result.Rows[0]["isAdmin"]);
        }

        return newUser;
    }

    public static User getUserById(int id)
    {
        System.Data.DataTable dt = MyDbase.SelectFromTable("select * from tUsers where id=" + id, "db.mdb");
        return getUserForSqlResult(dt);
    }

    public void saveUserChanges()
    {
        MyDbase.ChangeTable("UPDATE tUsers SET email='" + this.email + "', firstName='" + this.firstName + "', lastName='" + this.lastName +
                            "', passwd='" + this.passwd + "', birthDate='" + this.birthDate + "', phone='" + this.phone + "', avatarUrl='" +
                            this.avatarUrl + "' WHERE id=" + this.id , "db.mdb");
    }
}

I tried to run the following sample code just to make sure the select&update functions are working (Default.aspx):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

        User user = User.getUserById(3);
        user.setEmail("different@email.com");
        user.saveUserChanges();
    }
}

However, I get the following error:

Error 1 ‘System.Security.Principal.IPrincipal’ does not contain a
definition for ‘getUserById’ and no extension method ‘getUserById’
accepting a first argument of type
‘System.Security.Principal.IPrincipal’ could be found (are you missing
a using directive or an assembly reference?)

Any ideas why this might happen?
Tnx!

  • 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-17T09:12:00+00:00Added an answer on June 17, 2026 at 9:12 am

    Add a namespace to your User class to disambiguate between Page.User property and your User class

    using System;
    
    namespace MyUser
    {
        public class User
        {
           ....
        }
    }
    

    then in the Page_Load

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    
    public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
            MyUser.User user = MyUser.User.getUserById(3);
            user.setEmail("different@email.com");
            user.saveUserChanges();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't

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.