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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:30:11+00:00 2026-06-13T04:30:11+00:00

I have following code to set the text box values on page load. protected

  • 0

I have following code to set the text box values on page load.

protected void Page_Load(object sender, EventArgs e)
        {
            localhost.UserRegistration m = new localhost.UserRegistration();
            int user = m.ID(Session["Username"].ToString());
            DataSet ds = m.GetUserInfo(user);
            if (ds.Tables.Count > 0)
            {
                TextBox1.Text = ds.Tables[0].Rows[0]["emailAddress"].ToString();
                TextBox2.Text = ds.Tables[0].Rows[0]["password"].ToString();
            }


        }

So when first user opens the page, the user will be shown their email address and password in textbox. when they make changes and click update, the same value that was on page load will be sent to the database, not the new one that is changed.

I have the following web service method to update the user details

[WebMethod(Description = "Updates a single user")]
        public string UpdateUser(int user, string emailAddress, string password)
        {
            // Create connection object
            int ix = 0;
            string rTurn = "";
            OleDbConnection oleConn = new OleDbConnection(connString);
            try
            {
                oleConn.Open();
                string sql = "UPDATE [User] SET [emailAddress]=@emailAddress, [password]=@password" + " WHERE [ID]=@user";
                OleDbCommand oleComm = new OleDbCommand(sql, oleConn);

                oleComm.Parameters.Add("@user", OleDbType.Integer).Value = user;
                oleComm.Parameters.Add("@emailAddress", OleDbType.Char).Value = emailAddress;
                oleComm.Parameters.Add("@password", OleDbType.Char).Value = password;


                ix = oleComm.ExecuteNonQuery();
                if (ix > 0)
                    rTurn = "User Updated";
                else
                    rTurn = "Update Failed";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                rTurn = ex.ToString();
            }
            finally
            {
                oleConn.Close();
            }
            return rTurn;
        }

This is how table look in database

enter image description here

Client Side Code

protected void Button1_Click(object sender, EventArgs e)
        {


            string email = TextBox1.Text;
            string pass = TextBox2.Text;
            localhost.UserRegistration m = new localhost.UserRegistration();
            int usr = m.ID(Session["Username"].ToString());
            m.UpdateUser(usr, email, pass);

        }

Can Somebody tell me why….

  • 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-13T04:30:12+00:00Added an answer on June 13, 2026 at 4:30 am

    I think you are mixing up SqlParameters and OleDbParameters. OleDbParameters does not support named parameters!!

    see MSDN OleDbCommand.Parameters

    The OLE DB .NET Provider does not support named parameters for passing
    parameters to an SQL statement or a stored procedure called by an
    OleDbCommand when CommandType is set to Text. In this case, the
    question mark (?) placeholder must be used. For example:

    SELECT * FROM Customers WHERE CustomerID = ?

    Therefore, the order in which OleDbParameter objects are added to the
    OleDbParameterCollection must directly correspond to the position of
    the question mark placeholder for the parameter in the command text.

    I think you should adapt your code to

    ...
    oleConn.Open();
    string sql = "UPDATE [User] SET [emailAddress]=?, [password]=? WHERE [ID]=?";
    OleDbCommand oleComm = new OleDbCommand(sql, oleConn);
    
    oleComm.Parameters.Add("@emailAddress", OleDbType.Char).Value = emailAddress;
    oleComm.Parameters.Add("@password", OleDbType.Char).Value = password;
    oleComm.Parameters.Add("@user", OleDbType.Integer).Value = user;
    ...
    

    EDIT

    protected void Page_Load(object sender, EventArgs e)
    {
      if (!Page.IsPostBack)
      {
          localhost.UserRegistration m = new localhost.UserRegistration();
          int user = m.ID(Session["Username"].ToString());
          DataSet ds = m.GetUserInfo(user);
          if (ds.Tables.Count > 0)
          {
              TextBox1.Text = ds.Tables[0].Rows[0]["emailAddress"].ToString();
              TextBox2.Text = ds.Tables[0].Rows[0]["password"].ToString();
          }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in place, and it works: private void OnEvent(object sender,
I have following code. ASPX Page <a href=AnyASPXPageOfWebsite.aspx onclick=javascript:CallJQuery(); > Set Price </a> JS
I have the following set up, a ddl (ddlProd, radBuyer) and autocomplete text box
I have the following code set up in my Startup IDictionary<string, string> properties =
I have the following code to set a userId variable: (userId set in prior
I have following code in my application: // to set tip - photo in
I have the following code: UPDATE myTable SET Col1 = @Value However, I have
I have used the following code to set cookie and then redirect. String level=(String)
I have the following drawing code: [[NSColor redColor] set]; NSRect fillRect = NSMakeRect(bounds.size.width -
I have the following code: private static final Set<String> allowedParameters; static { Set<String> tmpSet

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.