Passing values in another textbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AllanJohnson
    New Member
    • Apr 2012
    • 7

    Passing values in another textbox

    Please help! kinda urgent...so please please help.
    I have an ms access database with 2 tables in it which I named Customers and Products. I am using visual studio 2010, in my windows form I have 4 textboxes and 3 button in it, for my 1st textbox when I entered one of my ProductCode such as 10111, then press the Display button, the other remaining 3 textboxes should populate and display the following;
    ProductID: CH001
    ProductName: Chocolate Strawberry
    ProductCode: 10111
    Then the 2 remaining button named NEXT and PREVIOUS, should be able to display all my product name with 10111 product code. Sincerely thanks in advance
  • RhysW
    New Member
    • Mar 2012
    • 70

    #2
    its unclear what you are asking, do you just want those words written into it or are those words coming from the database to populate the textboxes?

    Comment

    • AllanJohnson
      New Member
      • Apr 2012
      • 7

      #3
      sorry for unclear question, my english is bad..
      yes, the values are from my database. Thanks for replying.

      Comment

      • RhysW
        New Member
        • Mar 2012
        • 70

        #4
        is this a Microsoft access database of the visual studio code version using datasets and data tables?

        Comment

        • AllanJohnson
          New Member
          • Apr 2012
          • 7

          #5
          yes, youre right. Thanks for replying

          Comment

          • RhysW
            New Member
            • Mar 2012
            • 70

            #6
            which one? they are two different things and require different code to do.

            Comment

            • AllanJohnson
              New Member
              • Apr 2012
              • 7

              #7
              I am using ms access as my database and visual studio 2010 for my form
              and I am using DataSets, DataReader, DataAdpter.

              Comment

              • roshan ban
                New Member
                • Apr 2012
                • 21

                #8
                You can simply use the folloing code in display Button Click method
                Crate A connection and then open it
                then
                SqlCommand sqlcmd = new SqlCommand("Sel ect * From Product Where ProCode='" + ProductId + "'", yourConnection) ;
                Declare a sqldataReader and execute a sqlcommand and then finally bind the value to required textbox
                SqlDataReader sdrreader;
                sdrreader = sqlcmd.ExecuteR eader();
                if (sdrreader.Read ())
                {
                textBox2.Text = sdrreader["FieldName"].ToString();
                textBox3.Text = sdrreader["FieldName"].ToString();
                }
                sdrreader.Close ();

                Comment

                Working...