List Info

Thread: RE: want to get the next ID before inserting




RE: want to get the next ID before inserting
country flaguser name
United States
2007-08-22 17:41:00
Is it possible that they are used to Access Database forms
where they click
on new record and a record Id displays?  I have seen this
done is very old
data entry systems so if they are used to that it may be
hard to break them
of it. I would first try to educate them suggesting that
creating empty
records ahead of time could lead to additional man hours of
data scrubbing
that would need to be scheduled.

Pamela Reinskou
BCIP Certified Web Developer - Databases
VersusLaw, Inc.
Still Revolutionizing The Way America Does Law
http://www.versuslaw.com

425.250.0142



-----Original Message-----
From: merkimerk.com [mailto:merkimerk.com]On Behalf Of Ian
Lipsky
Sent: Wednesday, August 22, 2007 1:24 PM
To: aspnet-databasesaspadvice.com
Subject: [aspnet-databases] RE: want to get the next ID
before inserting


I dont really know why they need the ID before the recorded
has been
inserted. Chances are they dont know why they need it either
 But
they've asked that I display the ID before the record is
inserted.
i.e. someone opens a webpage to fill out a form and it
displays the ID
of the record before they ever hit submit.

I was doing it the way you described...they submit the form
and then i
display the ID of the new record.

ian

On 8/22/07, Brett Stinson <brett.stinsongmail.com> wrote:
> Ian:
>   Not sure what you are trying to do here, but what do
you need the next
id
> for before you do the actual insert?
>
> The way I have dealt with it in the past is to have my
stored procedure
pass
> the id of the just inserted record back to
> the calling code when the insert is complete.
> Would this meet your needs?
>
> Take a look at
> http://msdn2.microsoft.com/en-us/library/ms190315.aspx

> and
> http://www.google.com/search?hl=en&q=asp.net+
scope_identity
>
> HTH
>
> --
> Brett.Stinsongmail.com
>
> On 8/22/07, Ian Lipsky <aspadvice2imerk.net> wrote:
> >
> > Sequence DB object?
> >
> > Actually, I was planning on using a table with an
auto-id field, and
> > then insert a row to get the next ID and then
delete that row to keep
> > the table small.
> >
> > Ian
> >
> > On 8/21/07, PhilJackson <pjackson1hot.rr.com> wrote:
> > > Yep - having a column defined as an identity
(auto increment) or using
a
> > > Sequence DB object is certainly better.  I've
seen Keith's method used
> > > even in old systems that had nothing but IBM
VSAM files, with one file
> > > containing that "next number"
,etc.
> > >
> > >
> > >
> > > On Tue, 2007-08-21 at 18:08 -0600, Keith
Barrows [StarPilot] wrote:
> > > > One of the ways we did in "the old
days" before auto generated IDs
> > were the
> > > > rage was to have a table that was solely
responsible for dishing out
> > new
> > > > IDs.  Single column for the ID, sproc to
get the next ID and
increment
> > it.
> > > > Now, you have a unique ID that no one
else can ever have.  The only
> > caveat
> > > > is if it is thrown away:  You end up
with gaps in your
> > sequences.  C'est la
> > > > vie.
> > > >
> > > > ________________________________
> > > >
> > > > Keith Barrows
> > > >
> > > >
> > > >
> > > >
> > > > -----Original Message-----
> > > > From: merkimerk.com [mailto:merkimerk.com] On Behalf Of Ian Lipsky
> > > > Sent: Tuesday, August 21, 2007 4:29 PM
> > > > To: aspnet-databasesaspadvice.com
> > > > Subject: [aspnet-databases] want to get
the next ID before inserting
> > > >
> > > > asp.net 2.0 and sql 2000.
> > > >
> > > > I have a page that does an insert into
one table and an update on a
> > 2nd
> > > > table.
> > > >
> > > > I need to get the ID of the insert
before doing the insert. i.e.
they
> > want
> > > > the ID # displayed on the form before
they actually submit the form.
> > > >
> > > > I was thinking of just grabbing the
highest number ID in the table,
> > adding 1
> > > > to that and displaying that. But that
runs into problems if two
people
> > are
> > > > submitting at the same time.
> > > >
> > > > So i can think of two other ways of
doing this:
> > > >
> > > > 1. insert an empty record, get the ID
and display that and then do
an
> > update
> > > > instead of insert
> > > > 2. create a 2nd table with just an ID
field, insert into that, get
the
> > ID
> > > > and use that for my record ID.
> > > >
> > > > For the first one...it just seems messy
and i dont like having empty
> > records
> > > > ( i know I can schedule a proc to run to
clean them up)
> > > > I dont really like the 2nd option
either... still seems messy to me.
> > > >
> > > > but given the two, the first one makes
more sense to me. Seems
> > pointless to
> > > > have a 2nd table just to increment a
counter.
> > > >
> > > > Is there a better way?
> > > >
> > > > ian
> > > >
> > > >
> > > >
> > > > Need SQL Advice? http://sqladvice.com
> > > > Need RegEx Advice? http://regexadvice.com
> > > > Need XML Advice? http://xmladvice.com
> > > >
> > > > No virus found in this incoming
message.
> > > > Checked by AVG Free Edition.
> > > > Version: 7.5.484 / Virus Database:
269.12.1/963 - Release Date:
> > 8/20/2007
> > > > 5:44 PM
> > > >
> > > >
> > > > No virus found in this outgoing
message.
> > > > Checked by AVG Free Edition.
> > > > Version: 7.5.484 / Virus Database:
269.12.1/963 - Release Date:
> > 8/20/2007
> > > > 5:44 PM
> > > >
> > > >
> > > >
> > > >
> > > > Need SQL Advice? http://sqladvice.com
> > > > Need RegEx Advice? http://regexadvice.com
> > > > Need XML Advice? http://xmladvice.com
> > >
> > >
> > >
> > > Need SQL Advice? http://sqladvice.com
> > > Need RegEx Advice? http://regexadvice.com
> > > Need XML Advice? http://xmladvice.com
> > >
> > >
> >
> >
> > Need SQL Advice? http://sqladvice.com
> > Need RegEx Advice? http://regexadvice.com
> > Need XML Advice? http://xmladvice.com
> >
>
>
>
> Need SQL Advice? http://sqladvice.com
> Need RegEx Advice? http://regexadvice.com
> Need XML Advice? http://xmladvice.com
>
>


Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice? http://xmladvice.com


Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice? http://xmladvice.com

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )