Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: how to add2


Message #1 by "John Sen Yong" <yjohns@t...> on Thu, 19 Apr 2001 00:17:58 +0800
thanks for reply...

u say better use autonumber...

but my primary id starts from cid1,cid2...

so using autonumber or set increment, can it inteligently add from cid1 to

cid2?

if not, what solution i can have?

please help....





----- Original Message -----

From: Tomm Matthis <matthis@b...>

To: ASP Databases <asp_databases@p...>

Sent: Wednesday, April 18, 2001 5:21 AM

Subject: [asp_databases] RE: how to add





If you're using SQL INSERT Statements, don't reference the field... SQL will

automatcally fill it in correctly during the add... if you need to use that

number immediately then you have 2 choices.

1. Use a Command object to call a stored proc and have the proc return the

@@identity to you.

2. After an ADO.ADDNEW, the rs.bookmark with have the id in it... NOTE: this

is undocumented and may not be there in the next revision of ADO... so use

this trick at your own risk!!!



Tomm



Message #2 by "Thor Burfine" <tburfine@k...> on Wed, 18 Apr 2001 22:49:24
SQL and Access can do it

what you have to do is a the following



varNewCID="SELECT MAX CONVERT(Right(CID,Len(CID)-3),int)"

varNewCID=varNewCID+1



this gives you the highst number found and adds one to it after converting 

it to a number.



Hope this helps.

Thor







> thanks for reply...

> u say better use autonumber...

> but my primary id starts from cid1,cid2...

> so using autonumber or set increment, can it inteligently add from cid1 

to

> cid2?

> if not, what solution i can have?

> please help....

> 

> 

> ----- Original Message -----

> From: Tomm Matthis <matthis@b...>

> To: ASP Databases <asp_databases@p...>

> Sent: Wednesday, April 18, 2001 5:21 AM

> Subject: [asp_databases] RE: how to add

> 

> 

> If you're using SQL INSERT Statements, don't reference the field... SQL 

will

> automatcally fill it in correctly during the add... if you need to use 

that

> number immediately then you have 2 choices.

> 1. Use a Command object to call a stored proc and have the proc return 

the

> @@identity to you.

> 2. After an ADO.ADDNEW, the rs.bookmark with have the id in it... NOTE: 

this

> is undocumented and may not be there in the next revision of ADO... so 

use

> this trick at your own risk!!!

> 

> Tomm

> 

Message #3 by "John Sen Yong" <yjohns@t...> on Thu, 19 Apr 2001 14:35:14 +0800
thanx for ur response regarding my problem

can i know whether the field CID u meant , is autonumber or int datatype?

or it works both for int and autonumber?





----- Original Message -----

From: Thor Burfine <tburfine@k...>

To: ASP Databases <asp_databases@p...>

Sent: Wednesday, April 18, 2001 10:49 PM

Subject: [asp_databases] Re: how to add2





> SQL and Access can do it

> what you have to do is a the following

>

> varNewCID="SELECT MAX CONVERT(Right(CID,Len(CID)-3),int)"

> varNewCID=varNewCID+1

>

> this gives you the highst number found and adds one to it after converting

> it to a number.

>

> Hope this helps.

> Thor

>

>

>

> > thanks for reply...

> > u say better use autonumber...

> > but my primary id starts from cid1,cid2...

> > so using autonumber or set increment, can it inteligently add from cid1

> to

> > cid2?

> > if not, what solution i can have?

> > please help....

> >

> >

> > ----- Original Message -----

> > From: Tomm Matthis <matthis@b...>

> > To: ASP Databases <asp_databases@p...>

> > Sent: Wednesday, April 18, 2001 5:21 AM

> > Subject: [asp_databases] RE: how to add

> >

> >

> > If you're using SQL INSERT Statements, don't reference the field... SQL

> will

> > automatcally fill it in correctly during the add... if you need to use

> that

> > number immediately then you have 2 choices.

> > 1. Use a Command object to call a stored proc and have the proc return

> the

> > @@identity to you.

> > 2. After an ADO.ADDNEW, the rs.bookmark with have the id in it... NOTE:

> this

> > is undocumented and may not be there in the next revision of ADO... so

> use

> > this trick at your own risk!!!

> >

> > Tomm

> >

>




  Return to Index