M MTmace Member Joined Feb 1, 2005 Messages 9 Programming Experience Beginner Oct 28, 2005 #1 How would I select the max value of a datatable? intMaxID = Me.dsLossNotice.Tables("NameAddress").Select(???)
How would I select the max value of a datatable? intMaxID = Me.dsLossNotice.Tables("NameAddress").Select(???)
jmcilhinney VB.NET Forum Moderator Staff member Joined Aug 17, 2004 Messages 15,142 Location Sydney, Australia Programming Experience 10+ Oct 31, 2005 #2 You would need to use the DefaultView to Sort the rows and then take the first: VB.NET: myDataTable.DefaultView.Sort = "ID DESC" intMaxID = myDataTable.DefaultView(0)("ID") Upvote 0 Downvote
You would need to use the DefaultView to Sort the rows and then take the first: VB.NET: myDataTable.DefaultView.Sort = "ID DESC" intMaxID = myDataTable.DefaultView(0)("ID")
ManicCW Well-known member Joined Jul 21, 2005 Messages 428 Location Mostar Programming Experience Beginner Oct 31, 2005 #3 You can use query "SELECT MAX(TableName.ID) FROM TableName" Upvote 0 Downvote