954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Auto generation of numbers..

Hi all webbers,
I have a problem of generating numbers automatically....
Actually i have a textbox and the textbox should autogenerate a number everytime the page loads or whenever the user clicks the next button after filling in the values.....

Help me out dudes.......Sample code would help me a lot.....

bharathi_n_r
Light Poster
25 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 

Can you describe the number? Something completely (pseudo)random? A unique ID? A sequence number? What you're using it for determines how you generate it.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

I am using the numbers for serializing my datas..The numbers should generate automatically like 1 for the first record 2 for the second 3, 4 ,5 etc...But the number should continue even he logs out and logs in next time.The form contains Issue number, Name,Address,Issue Date etc...I want the issue number to get generated automatically.....I hope it clears ur question...!

bharathi_n_r
Light Poster
25 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 

Dude,
I managed to generate the numbers,but i have a little problem.I have given this code in my page load event to fetch the last record from the database and increment the value of issue_no by one.It is incrementing the value but once i click the add button after filling other details,the next number is not getting incremented after the button click,any suggestion man....It is getting incremented after i sttoped and then running my program again....
I want the next no to be incremented so that the user can enter multiple datas without closing the application....

Con = new SqlConnection("Data Source=PSTLCORPSERV;Initial Catalog=Error;Persist Security Info=True;User ID=sa;Password=sqlserver12#");
            Con.Open();
            Cmd = new SqlCommand("select issue_no from error", Con);
            Data = Cmd.ExecuteReader();
            while (Data.Read() != false)
            {

                auto = Data.GetString(0);	

            }
            try
            {

                int newid = Int32.Parse(auto);
                int id = newid + 1;
                this.textBox1.Text = id.ToString() + "";

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.Source);
            }

            Data.Close();
bharathi_n_r
Light Poster
25 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 

your code is true but did a little more.
make the procedure or function to generate auto number only. so you can call this procedure or function after you add,edit,delete or clear form.

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You