[2008] Access [SQL] Getting Last Row?
Hi. I'm currently stuck on a part in my application.
vb Code:
SQL = "SELECT CourseID FROM Overview"
Adapter = New OleDbDataAdapter(SQL, Connection)
DS = New DataSet
Adapter.Fill(DS)
If DS.Tables(0).Rows.Count > 0 Then
NewTableName = DS.Tables(0).Rows().Item("CourseID").ToString()
End If
What I'm trying to do. is when the Application Loads, I need it to get the Last INDEX in the CourseID Form and I guess add 1 to it. I forget how do it, but I believe its something to do with Reader and a Integer I guess. Like While Reader = True then Count + 1.
How would I go about doing this? Its something in here
NewTableName = DS.Tables(0).Rows(!HERE!).Item("CourseID").ToString()
That I'm going need a variable or something.
Re: [2008] Access [SQL] Getting Last Row?
Re: [2008] Access [SQL] Getting Last Row?
If you're saying that you need to get the last row then, like every collection, it's at index (Count - 1).
vb.net Code:
Dim table As DataTable = DS.Tables(0)
Dim lastRow As DataRow = table.Rows(table.Rows.Count - 1)
Re: [2008] Access [SQL] Getting Last Row?
vb Code:
Dim table As DataTable = DS.Tables(0)
Dim TableRow As DataRow = table.Rows(table.Rows.Count - 1)
If DS.Tables(0).Rows.Count > 0 Then
NewTableName = DS.Tables(0).Rows(TableRow).Item("CourseID").ToString()
End If
Can't Convert Integer into DataRow
How do I make TableRow a Integer while keeping the table.Rows(table.Rows.Count -1) ? I'm trying to get the last index then set it to add to that on a NEW TABLE
Re: [2008] Access [SQL] Getting Last Row?
Wow I'm stupid, I just looked at my IF statment and used that
vb Code:
Dim TableRow As Integer = DS.Tables(0).Rows.Count - 1
If DS.Tables(0).Rows.Count > 0 Then
NewTableName = DS.Tables(0).Rows(TableRow).Item("CourseID")
End If