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