943,712 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 11020
  • C# RSS
Jan 19th, 2008
0

Auto generation of numbers..

Expand Post »
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.....
Last edited by bharathi_n_r; Jan 19th, 2008 at 2:35 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
bharathi_n_r is offline Offline
25 posts
since Jan 2008
Jan 19th, 2008
0

Re: Auto generation of numbers..

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.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Jan 21st, 2008
0

Re: Auto generation of numbers..

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...!
Reputation Points: 10
Solved Threads: 0
Light Poster
bharathi_n_r is offline Offline
25 posts
since Jan 2008
Jan 21st, 2008
0

Re: Auto generation of numbers..

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....
C# Syntax (Toggle Plain Text)
  1. Con = new SqlConnection("Data Source=PSTLCORPSERV;Initial Catalog=Error;Persist Security Info=True;User ID=sa;Password=sqlserver12#");
  2. Con.Open();
  3. Cmd = new SqlCommand("select issue_no from error", Con);
  4. Data = Cmd.ExecuteReader();
  5. while (Data.Read() != false)
  6. {
  7.  
  8. auto = Data.GetString(0);
  9.  
  10. }
  11. try
  12. {
  13.  
  14. int newid = Int32.Parse(auto);
  15. int id = newid + 1;
  16. this.textBox1.Text = id.ToString() + "";
  17.  
  18. }
  19. catch (Exception ex)
  20. {
  21. MessageBox.Show(ex.Message + ex.Source);
  22. }
  23.  
  24. Data.Close();
Last edited by bharathi_n_r; Jan 21st, 2008 at 2:47 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
bharathi_n_r is offline Offline
25 posts
since Jan 2008
Jan 22nd, 2008
0

Re: Auto generation of numbers..

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.
Last edited by Jx_Man; Jan 22nd, 2008 at 3:47 pm.
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,138 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Running my application outside the enviroment
Next Thread in C# Forum Timeline: question in C#





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC