Solved

VB.net SQL selecting the last record appended

Posted on 2011-09-09
3
277 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now