Solved

VB.net SQL selecting the last record appended

Posted on 2011-09-09
3
276 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
Comment Utility
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
Comment Utility
Great answer. Didn't expect that. Thanks
0
 

Author Comment

by:murbro
Comment Utility
To clarfy the MAX part sufficed
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

763 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

8 Experts available now in Live!

Get 1:1 Help Now