Solved

VB.net SQL selecting the last record appended

Posted on 2011-09-09
3
280 Views
Last Modified: 2012-05-12
Hi.
In Vb.net I am appending data to a SQL database using the following code
    oSQL = "Insert Into Table1 ([oDate],[oText], [oNumber]) Select '" & oDate & "' as Expr1, '" & oText & "' as Expr2, " & oNumber & " as Expr3"
I want to select the last row appended to make sure that it actually was. Since the ID field is automatically generated this is a little tricky
0
Comment
Question by:murbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
DrewKjell earned 500 total points
ID: 36510351
SELECT MAX(<YOURIDFIELD>)
FROM Table1

Or if it's an Identity field you can look into SCOPE_IDENTITY().

What exactly are you wanting to do with selecting the record back?

Drew
0
 

Author Closing Comment

by:murbro
ID: 36510521
Great answer. Didn't expect that. Thanks
0
 

Author Comment

by:murbro
ID: 36510533
To clarfy the MAX part sufficed
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question