Update value in database where value in textbox is equal to specific field in table.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sharma Neha
    New Member
    • Jul 2008
    • 22

    Update value in database where value in textbox is equal to specific field in table.

    How can i update the values in a table in database.The condition to update is a value in a textbox.
    I hav a textbox containing the order value.The table order_detail should be updated for its some values like shipment date,transporte r name etc where order no is equql to the value in the textbox(contain g order no).?
    plz suggest me some ways....thanks for your help.
  • jhaxo
    New Member
    • Dec 2007
    • 57

    #2
    Try this link for how the sql update statement works. It might be what you are looking for.

    http://www.w3schools.c om/Sql/sql_update.asp

    Comment

    • Curtis Rutland
      Recognized Expert Specialist
      • Apr 2008
      • 3264

      #3
      Look in the "how to" section for the articles on how to use a db in your .net program part 1&2. sorry no link, posting from my phone.

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Links:
        How to Use A Database In Your .NET Program
        How to Use A Database In Your .NET Program Part II

        This should tell you what you need to know to use databases in your programs.

        Comment

        • Sharma Neha
          New Member
          • Jul 2008
          • 22

          #5
          thanks for ur answers.
          i know the connection and sql query details.But my problem is that when i am
          giving specific values in where clause and the set clause it is working,but when i m
          writing like....
          update emp set emp_name=textBo x1.Text where roll_no=textBox 2.Text;

          error ic coming-MULTI-PART IDENTIFIER 'textBox2.text' CAN NOT BE BOUND.
          SO THE PROBLEM IS THAT IT IS NOT TAKING THE VALUES IN TEXTBOX,IT IS ONLY USING THE SPECIFIC VALUES.


          This statement is working
          update emp set emp_name='neha' where roll_no=2;

          plzzzzzzz reply if u know the ans.

          Comment

          • Curtis Rutland
            Recognized Expert Specialist
            • Apr 2008
            • 3264

            #6
            Ok. Your original question was misleading. Here's a code sample that will show you how do do a parameterized query. This way, you just plug in parameters, and then define those parameters later and give them values.

            Code:
            string update = "update test set fName=@fName where id=@id";
            OleDbCommand cmd = new OleDbCommand(update, conn);
            cmd.Parameters.AddWithValue("@fName", TextBox1.Text);
            cmd.Parameters.AddWithValue("@id", Convert.ToInt32(TextBox2.Text));

            Comment

            • Sharma Neha
              New Member
              • Jul 2008
              • 22

              #7
              thanks for help.this code is working.

              Comment

              • Curtis Rutland
                Recognized Expert Specialist
                • Apr 2008
                • 3264

                #8
                Happy to have helped.

                Comment

                Working...