Results 1 to 3 of 3

Thread: simple database question

  1. #1

    Thread Starter
    Lively Member afterMoon's Avatar
    Join Date
    Oct 2002
    Location
    cochin
    Posts
    117

    simple database question

    how would i get the max value of a datbase field?
    in vb6, i could've write

    rs.open("select max(id) from table",cn)

    how can i get this value in vb.net?

    thanks in advance
    when in doubt, win the trick

  2. #2
    Addicted Member
    Join Date
    Oct 2002
    Posts
    145
    hi,

    VB Code:
    1. cmSQL = New SqlCommand("select max(id) from table",cnSQL)
    2. Dim maxid As Integer = cmSQL.ExecuteScalar()

    hope this helps.

    Marivic

  3. #3

    Thread Starter
    Lively Member afterMoon's Avatar
    Join Date
    Oct 2002
    Location
    cochin
    Posts
    117
    thanks Marivic. it worked perfectly
    thanks again
    when in doubt, win the trick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width