Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 December 27th, 2007, 09:41 PM
Authorized User
 
Join Date: Dec 2007
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
Default identify increase automatic

Hello everybody
I am very fun if you can help me a problem about identify increase automatic by access.
How can i do that.please help me
ex: id=P001ID identify before
 when i add another field that increase id=P002ID
Thanks so much to your help
Regards
Hoang Phuc


 
Old January 3rd, 2008, 06:18 PM
Authorized User
 
Join Date: Dec 2007
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via ICQ to vanik.cz
Default

can you write it in other words? Do you want to identify the field that you have to insert into the table and it have automatic number and you dont know it? or what?

JVV
 
Old January 10th, 2008, 04:31 AM
Authorized User
 
Join Date: Dec 2007
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Have a good day!
It is useful for me so i Clarify want to say:
My database that have a field,the name is categoryID ,type is text
when i insert a new field but i want to default is C001ID and then if i save an another field .that increase is C002ID,..and then add,C003ID,C004ID...
Thanks so much
Regards
Hoang Phuc

 
Old January 10th, 2008, 09:58 AM
Authorized User
 
Join Date: Dec 2007
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via ICQ to vanik.cz
Default

Im not sure about that is possible... yes field can contain some precomputed value but I dont know if it has this capability... You can use automatic number as Index key and use value from it and if you need the field with text value that you are talking about, you can compute it automaticaly maybe, but I dont know why do you need it...
numbers as a key is better than your limited schema... For users you can show another computed value that is computed from the database number field.

JVV
 
Old January 10th, 2008, 08:00 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

mmmmm I think its strange generating your own unique strings however there are times when its neccessary. What you are trying to achieve can be done very easily.

Firstly when you say:

;;;when i insert a new field but i want to default is C001ID and then if i save an another field .that increase is C002ID,..and then add,C003ID,C004ID...

You use the word 'field' do you mean a new entry or record into the data base? I believe, and will assume this is what you want.

I would process the following code on the page before you carry our your data base transaction. This makes it more portable. EG one day you may cut your back end over to SQL Server or sone other type of data store.

This code and instructions below assumes:
>The beginning of the string will always be 'C00' (case sensitive)
>The end of the string will always be 'ID' (case sensitive)

  'get most recent number you are up to out of your database. The best way I
  'have found to do this is always have an field called ID (call it what ever
  'you like) make this a primary key and set the data type to 'AutoNumber'
  'the sql syntax to get the higest record I use is:

  sql = "SELECT TOP 1 id from tableName ORDER BY id DESC;"
  'execute you sql statement now and assign the value to a variable
  dim storedVariable
  myRecordSetName(0) = storedVariable
  'now string a few functions together to tweak your string. How I have done it:
  '> strip the C00 from ther beginning (use the mid function)
  '> strip the ID from the end of the string (use the replace function)
  '> increase our recently extracted number (simple addition)
  '> append the C00 and the ID to our new number (simple cancantenation)

  'here is the code you need:
  response.write ("C00" & (replace(Mid(storedVariable, 4),"ID","")+1) & "ID")



Wind is your friend
Matt
www.elitemarquees.com.au





Similar Threads
Thread Thread Starter Forum Replies Last Post
can we identify the text in the XSLT? rajatake XSLT 7 March 22nd, 2007 08:28 AM
How to know/identify that installation is done shiby_chacko1@rediffmail. C# 1 March 30th, 2005 03:21 AM
How to identify the computer Name MuthuAL Classic ASP Databases 2 December 22nd, 2004 08:42 AM





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