Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2004

Tip: Looking for answers? Try searching our database.

Get the last record in a dataset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
- 02 Aug 2004 15:19 GMT
I am trying to move to the last record in a dataset and find out the next incremented number that will be created via an insert. I a have tried a count but this does not quite do as I need. As the number of records does not relate to the next incremented number. Could anybody help me with this please??
Ignacio Machin \( .NET/ C#  MVP \) - 02 Aug 2004 15:29 GMT
hi,

select top 1 fieldname from table order by fieldname desc

cheers,

Signature

Ignacio Machin,
ignacio.machin AT dot.state.fl.us

> I am trying to move to the last record in a dataset and find out the next incremented number that will be created via an insert. I a have tried a
count but this does not quite do as I need. As the number of records does
not relate to the next incremented number. Could anybody help me with this
please??

> **********************************************************************
> Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
> Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
GirishKumar - 03 Aug 2004 11:35 GMT
This can also help you:
select  max(fieldname) from tablename

you can obtain the new value by using:

select max(fieldname)+1 from tablename

Note: assume the new value is last value plus 1

Signature

Girish Kumar
ICICI Infotech

"Ignacio Machin ( .NET/ C#  MVP )" wrote:

> hi,
>
[quoted text clipped - 12 lines]
> > Comprehensive, categorised, searchable collection of links to ASP &
> ASP.NET resources...
Andy Becker - 02 Aug 2004 17:03 GMT
> I am trying to move to the last record in a dataset and find out the next incremented number that will be created via an insert. I a have tried a
count but this does not quite do as I need. As the number of records does
not relate to the next incremented number. Could anybody help me with this
please??

Ignacio's bit of SQL can help you in a single-user environment, assuming you
are not using any identity columns in the database.  With multi-user or
identities, things get messier...

Mind if I ask what you want to do with the value?  There might be a
different way to do what you're after.

Best Regards,

Andy

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.