Auto generation of numbers..

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 25
Reputation: bharathi_n_r is an unknown quantity at this point 
Solved Threads: 0
bharathi_n_r bharathi_n_r is offline Offline
Light Poster

Auto generation of numbers..

 
0
  #1
Jan 19th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,698
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 729
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Auto generation of numbers..

 
0
  #2
Jan 19th, 2008
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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 25
Reputation: bharathi_n_r is an unknown quantity at this point 
Solved Threads: 0
bharathi_n_r bharathi_n_r is offline Offline
Light Poster

Re: Auto generation of numbers..

 
0
  #3
Jan 21st, 2008
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...!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 25
Reputation: bharathi_n_r is an unknown quantity at this point 
Solved Threads: 0
bharathi_n_r bharathi_n_r is offline Offline
Light Poster

Re: Auto generation of numbers..

 
0
  #4
Jan 21st, 2008
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....
  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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Auto generation of numbers..

 
0
  #5
Jan 22nd, 2008
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.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC