Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Pa help po sa auto generate ID number vb.net 2010

mhelski123

The Devotee
Advanced Member
Messages
367
Reaction score
0
Points
26
Mga ka symbianize. Pa help po paano po ako mag gegenerate ng id. Example symb-2016-0001? tapos kapag 2015 po yung year dapat magiging symb-2015-0001 naman pero kapag same ng year dapat mag + 1. salamat po sa tutulong thank you in advance.
 
One option that you can do is that:

1. In your database structure, separate the Year and the 4-digit Identification.
2. In your query, Select the record given the year and maximum 4-digit identification.
i.e. SELECT * FROM table WHERE year = '2016/01/01' ORDER BY identification DESC LIMIT 0 1
3. Then on VB.Net, you can do a condition like so:
(pseudocode)
if( record > 0 ) {
getTheIdFromRecord();
incrementTheIdByOne();
} else {
getTheCurrentYear();
createAnInitialId()
saveTheYearAndIdToDatabase()
}

Cheers!
 
One option that you can do is that:

1. In your database structure, separate the Year and the 4-digit Identification.
2. In your query, Select the record given the year and maximum 4-digit identification.
i.e. SELECT * FROM table WHERE year = '2016/01/01' ORDER BY identification DESC LIMIT 0 1
3. Then on VB.Net, you can do a condition like so:
(pseudocode)
if( record > 0 ) {
getTheIdFromRecord();
incrementTheIdByOne();
} else {
getTheCurrentYear();
createAnInitialId()
saveTheYearAndIdToDatabase()
}

Cheers!

Ok sir. try ko to salamat po

- - - Updated - - -

Any idea pa po ba ? dko makuha eh. thanks
 
separate mo ts ng column yung number and year
1. retrieve mo yung field if null or blank bigyan mo na agad ng year + 0001
2. if me laman retrieve mo last order by id desc limit 1 if hindi mag match yung year number = year + 0001
3. sa view concatenate mo na lang yung year sa number , ang isang tanong dyan ts paano kung umabot na sa max 9999 pero dpa tapos ang year? if possible lang naman haha
 
Same problem here. Okay na yung database ko, yung code nalang. Ang problem ko now is di ko maretrieve yung laman ng database ko sa year. Example
(select id_no from tbl_id where year = yung year ngayon.) Di naman ako pwede maglagay ng static value na pagcocomparan. Salamat!
 
Same problem here. Okay na yung database ko, yung code nalang. Ang problem ko now is di ko maretrieve yung laman ng database ko sa year. Example
(select id_no from tbl_id where year = yung year ngayon.) Di naman ako pwede maglagay ng static value na pagcocomparan. Salamat!

Gamit ka po ng MID para makuha mo ung year sa id.
Para sa Year
try mo itong code

Dim Cur_Year as string = Format(DateTime.Now,"yyyy")

for example my ID ka na "SYMB-2016-0018" sa Textbox mo
gusto mo icompare ung date then
ito ung code

Dim ID_Year as string = Mid(TextBox1.Text,6,4)

if ID_Year = Cur_Year then
'do your code here
else
'do your code here
end

S Y M B - 2 0 1 6 - 0 0 1 8
1 2 3 4 5 6 7 8 9 10 11 12 13 14
 
Back
Top Bottom