Having Two Auto Numbers..

Please support our MS SQL 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

Having Two Auto Numbers..

 
0
  #1
Nov 17th, 2008
Hi Fellows,
Well. let me start by higlighting the problem i face.I have two columns namely PID which is the primary key and also a auto number.The second is Serial No. which is also a auto number.

The problem i face is that when i submit my form spcifying a month i want my serial no. to start from one and and end with the number of records in my Datagrid.

IF i come to the same and select a different month the PID should continue from where the last auto no. is but my serial no should start from 1 again..

Is there any option to do like this.Both PID and Serial No. are in the same table.


Thanks
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 144
Reputation: sierrainfo is an unknown quantity at this point 
Solved Threads: 9
sierrainfo sierrainfo is offline Offline
Junior Poster

Re: Having Two Auto Numbers..

 
0
  #2
Nov 17th, 2008
You can set a trigger on Insert Button as check the month for inserting record and previous record. It both are different then reset Serial No. and then insert.

Or

Click of submit button check the month of previous record and reset the Serial No. and the execute the insert command.
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: Having Two Auto Numbers..

 
0
  #3
Nov 17th, 2008
Thanks man,
I just checked it out... Sql wont allow me to have two auto no's.Is there any other option in code to do this and how to reset serial no to one without deleting the data.
I am using vb.net 1.1
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: Having Two Auto Numbers..

 
0
  #4
Nov 17th, 2008
Fellows,
I have found another option to do this(via Code).Instead of checking the month while submitting, i have found a way to count the number of rows using the dataset property
  1. dsEmployee.TABLES(0).Rows.Count

It is returning me the number of rows in my datagrid.I will write a for loop and form an ary to start from one and increment it till the last row of datagrid...Thanks for the replies..I hope some one will use this...

Thanks and Regards
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 144
Reputation: sierrainfo is an unknown quantity at this point 
Solved Threads: 9
sierrainfo sierrainfo is offline Offline
Junior Poster

Re: Having Two Auto Numbers..

 
0
  #5
Nov 17th, 2008
If Data is so large it will affect the performance due to For Loop

Thanks
Bye.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



Tag cloud for MS SQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC