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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:02:39+00:00 2026-05-26T04:02:39+00:00

i have a problem, i tried this code : private void button1_Click(object sender, RoutedEventArgs

  • 0

i have a problem, i tried this code :

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        conn.Open();
        OleDbCommand cmd = new OleDbCommand("UPDATE tbl_Fullname SET Firstname=@firstn,Lastname=@lastn,Middlename=@midn WHERE fnID=@idn", conn);

        cmd.Parameters.Add("@idn", OleDbType.VarChar).Value = textBox5.Text;
        cmd.Parameters.Add("@firstn", OleDbType.VarChar).Value = textBox1.Text;
        cmd.Parameters.Add("@lastn", OleDbType.VarChar).Value = textBox2.Text;
        cmd.Parameters.Add("@midn", OleDbType.VarChar).Value = textBox3.Text;
        cmd.ExecuteNonQuery();
        conn.Close();
    }

there was no error but when i ckecked my db access there is nothing changed.

is this the exact code for updatint and editing?

here is my whole code:

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {

    }

    private void button3_Click(object sender, RoutedEventArgs e)
    {

        OleDbCommand cmd = new OleDbCommand("INSERT INTO tbl_Fullname (Lastname,Firstname,Middlename) VALUES (@first,@last,@midn)",conn);

        conn.Open();
        cmd.Parameters.Add("@first", OleDbType.VarChar).Value = textBox1.Text;
        cmd.Parameters.Add("@last", OleDbType.VarChar).Value = textBox2.Text;
        cmd.Parameters.Add("@midn", OleDbType.VarChar).Value = textBox3.Text;
        cmd.ExecuteNonQuery();
        conn.Close();
    }

    private void textBox4_TextChanged(object sender, TextChangedEventArgs e)
    {
        conn.Open();
        OleDbCommand cmd2 = new OleDbCommand("SELECT fnID,Lastname,Firstname,Middlename FROM tbl_Fullname WHERE fnID= @id", conn);


        cmd2.Parameters.Add("@id", OleDbType.VarChar).Value = textBox4.Text;
        try
        {
            OleDbDataReader dr = cmd2.ExecuteReader();
            if (dr.Read())
            {
                textBox1.Text = dr[1].ToString();
                textBox2.Text = dr[2].ToString();
                textBox3.Text = dr[3].ToString();
                textBox5.Text = dr[0].ToString();

            }
            else
            {
                MessageBox.Show("No result");
            }

        }
        catch (Exception ex)
        {


            MessageBox.Show(ex.Message);
        }
        conn.Close();

    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        conn.Open();
        OleDbCommand cmd = new OleDbCommand("UPDATE tbl_Fullname SET Firstname=@firstn,Lastname=@lastn,Middlename=@midn WHERE fnID=@idn", conn);

        cmd.Parameters.Add("@idn", OleDbType.VarChar).Value = textBox5.Text;
        cmd.Parameters.Add("@firstn", OleDbType.VarChar).Value = textBox1.Text;
        cmd.Parameters.Add("@lastn", OleDbType.VarChar).Value = textBox2.Text;
        cmd.Parameters.Add("@midn", OleDbType.VarChar).Value = textBox3.Text;
        cmd.ExecuteNonQuery();
        conn.Close();
    }
}

}

i hope someone can help me. i need it badly. thank you in advance.

  • 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-26T04:02:40+00:00Added an answer on May 26, 2026 at 4:02 am

    MSDN says:

    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.

    So make it that way:

     private void button1_Click(object sender, RoutedEventArgs e)
        {
            conn.Open();
            OleDbCommand cmd = new OleDbCommand("UPDATE tbl_Fullname SET Firstname=?,Lastname=?,Middlename=? WHERE fnID=?", conn);
    
            cmd.Parameters.Add("@firstn", OleDbType.VarChar).Value = textBox1.Text;
            cmd.Parameters.Add("@lastn", OleDbType.VarChar).Value = textBox2.Text;
            cmd.Parameters.Add("@midn", OleDbType.VarChar).Value = textBox3.Text;
            cmd.Parameters.Add("@idn", OleDbType.VarChar).Value = textBox5.Text;
            cmd.ExecuteNonQuery();
            conn.Close();
        }
    

    Note that order of parameters is important here!

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

Sidebar

Related Questions

I have this code : private void vicationDataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (zawag)
I have tried this approach/hack: http://blog.blackwhale.at/2009/06/uibuttons-in-uinavigationbar/ The problem is this leaves a faint seam.
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem installing simple Windows Service, my code looks like this: using System;
I have a table in SQL Server which looks like this: ID Code Name
we have a weired problem when using Rhino Mocks and Threads. I've tried to
I'm learning functional programming, and have tried to solve a couple problems in a
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am

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.