increment value of textbox and save it in the database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Salin786
    New Member
    • Dec 2012
    • 5

    increment value of textbox and save it in the database

    I have a text box invoice no on windows form and i need to retrieve data from database and everytime user click on the add button the invoice no should increment by 1
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    Bytes.com isn't a code or homework service, we're a community of like minded people who come together to help those who are willing to help themselves.

    Show us what you've tried and we will do everything we can to nudge you in the right direction but we will not just do the work for you.

    Comment

    • Salin786
      New Member
      • Dec 2012
      • 5

      #3
      Code:
      private void button3_Click(object sender, EventArgs e)
              {
                  con.Open();
                  da = new SqlDataAdapter("Select UserId from tab_userinformation ",con);
                  ds = new DataSet();
                  da.Fill(ds);
                  textBox1.Text = ds.Tables[0].Rows[0][0].ToString();
                  con.Close();
              }
      Last edited by Rabbit; Dec 24 '12, 04:05 PM. Reason: Please use code tags when posting code.

      Comment

      • Salin786
        New Member
        • Dec 2012
        • 5

        #4
        Code:
        textbox.text = Convert.ToString(Convert.ToInt(textbox.text) + 1)
        incrementing the User id Bt i am getting it 302 instead of 301
        Last edited by Rabbit; Dec 24 '12, 04:05 PM. Reason: Please use code tags when posting code.

        Comment

        • Salin786
          New Member
          • Dec 2012
          • 5

          #5
          i have just put it up my code

          Comment

          • PsychoCoder
            Recognized Expert Contributor
            • Jul 2010
            • 465

            #6
            I'm not understanding what it is you're having trouble with, or what you're trying to accomplish for that matter.

            Comment

            • hoemach
              New Member
              • Dec 2012
              • 1

              #7
              Have you tried DMax +1?

              Comment

              • adriancs
                New Member
                • Apr 2011
                • 122

                #8
                use auto-increment int primary key and column data type.
                the database will do it for you automatically.

                Comment

                Working...