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

Having Two Auto Numbers..

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

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

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.

sierrainfo
Junior Poster
144 posts since May 2008
Reputation Points: 10
Solved Threads: 9
 

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

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

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

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

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

If Data is so large it will affect the performance due to For Loop

Thanks
Bye.

sierrainfo
Junior Poster
144 posts since May 2008
Reputation Points: 10
Solved Threads: 9
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You