Jump to content
sadis

Unique Id Guna Asp

Recommended Posts

Salam,

ada sesapa sini yg teror mintak tlg bantu.
saya try utk create function generate unique id guna asp @vb scripts..
unique id format camni, AP-AA-0000. hanya AA-0000 akan berubah. cth dia akan count sampai AA-9999 then start ngan AB-0001 pulak dan seterusnya la.

mintak tolong sapa yg penah buat.

Share this post


Link to post
Share on other sites
[quote name='sadis' date='01 July 2010 - 05:08 PM' timestamp='1277975309' post='1039865']
Salam,

ada sesapa sini yg teror mintak tlg bantu.
saya try utk create function generate unique id guna asp @vb scripts..
unique id format camni, AP-AA-0000. hanya AA-0000 akan berubah. cth dia akan count sampai AA-9999 then start ngan AB-0001 pulak dan seterusnya la.

mintak tolong sapa yg penah buat.
[/quote]


buat macam nie...

1. read dari DB last inserted number secara descending..macam nie.."Select top 1 <field> from <table> order by <field> DESC"
2. kalau x de value dari db..masukkan data(initial value) macam y ko nak tu.. "AP-AA-0000"
3. lepas dah masukkan, ko update number tu guna function nie...(ak pakai c# ko pandai2 la convert kan)

[code]

public void updateRunningCode()
{
string noPangkal = valueDariDB.substring(0,2);
int runningTemp = Convert.ToInt32(valueDariDB.substring (5,10));
runningTemp++;


[b] if(runningTemp <10000)
{
string runningCode = noPangkal + "AA" + String.Format("{0:0000}", runningTemp);

}[/b]
}

[/code]

(part y ak bold kan tu ko pk kan sendiri..ak x sure ade ke x string format utuk ABC )
lepas dah update no tu..store balik dalam db..

sekian...harap dapat mmbantu..

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...