Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 2nd, 2004, 10:14 AM
Registered User
 
Join Date: Oct 2004
Location: , , .
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

  #2 (permalink)  
Old November 2nd, 2004, 05:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
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
  #3 (permalink)  
Old November 3rd, 2004, 04:56 AM
Registered User
 
Join Date: Oct 2004
Location: , , .
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


  #4 (permalink)  
Old November 9th, 2004, 08:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:50 PM.


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