0

Im having problems with my ms acess sql command, well im trying to get the last value from the database

here is my code, the error is ORDER BY clause syntax error..

data.Open()

record.SelectCommand = New OleDbCommand("SELECT PatientID FROM PatientRecord ORDER BY PatientID desc LIMIT 1", data)

Dim ds As New DataSet

Dim dr As DataRow

record.Fill(ds)

dr = ds.Tables(0).Rows(0)

TextBox1.Text = dr(0)

Or is there any alternative to get the last row from the database? Thank you all

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by ivatanako
0

Since it is ms access that you are using, you could use

SELECT LAST(columnname) FROM tablename

or

SELECT MAX(columnname) FROM tablename

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.