Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 2nd, 2004, 10:14 AM
Registered User
 
Join Date: Oct 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creaing Dynamic generic Cust ID

I am trying to create this customer ID which has some parameters
contatinated like
WD as the first two parameters then the next two are location name which is numeric and then the next two are center id which is numeric and then the sequence id which incremented with each new record inserted .
  NOw can any one please tell me the code or logic to do it

MY Id will look something like this
WD217 ,WD218,

CAUTION: except for WD all other parameters are retreived from database

 
Old November 2nd, 2004, 05:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Srichary,

Are you extracting the LocationId, CenterId and SequenceID all based on some criteria? If so what is that? You can use something like this.
Code:
SELECT 'WD' + cast(LocationId as varchar(5)) + cast(CenterId as varchar(5)) + 
    (select Cast(Coalesce(1,max(SequenceId)) as varchar(5)) 
    FROM TABLENAME WHERE criteria_if_required) 
from TABLENAME WHERE criteria_if_required
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old November 3rd, 2004, 04:56 AM
Registered User
 
Join Date: Oct 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Vijay,
  Thanks .You know once it gets used to it becomes easier;) well i could figure out how to do it.
 heres the logic....
wlkid contains the DB value of the max ID and lid is the location id and cenid is center id


if len(walkid) = 1 then
wkid="WD"& lid & cenid & "00000" & walkid
elseif len(walkid) = 2 then
wkid="WD"& lid & cenid & "0000" & walkid
elseif len(walkid) = 3 then
wkid="WD"& lid & cenid & "000" & walkid
elseif len(walkid) = 4 then
wkid="WD"& lid & cenid & "00" & walkid
elseif len(walkid) = 5 then
wkid="WD"& lid & cenid & "0" & walkid
elseif len(walkid) = 6 then
wkid="WD"& lid & cenid & walkid
end if


 
Old November 9th, 2004, 08:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Srichary,

Glad that you solved that. But you didnot mention about fixing ZEROs based on the length of WALKID, else the one I posted would be an easier solution. Still I wasn't sure if you are using ACCESS/MS SQL server. My solution could work only for SQL server, not for MS Access.

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
creaing user form with vba sms Access VBA 3 June 13th, 2008 07:50 AM
Generic & Dynamic XSLT but small problem..help pulin XSLT 3 April 29th, 2007 05:42 PM
'this.ID = id;' in class construction holf BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 October 6th, 2006 10:58 AM
why not index.asp?id=1 can be www.myweb.com/?id=1 BurhanKhan Classic ASP Professional 11 September 6th, 2004 02:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.