Results 1 to 2 of 2

Thread: Getting a dataset value

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    Tennessee
    Posts
    279

    Getting a dataset value

    I've pulled a dataset into a datagrid and now I need the max(id) of the dataset. I've sorted them ascending so I know that the highest id will be the last one but I'm having trouble getting an individual field value like we did in VB6 with ado recordsets:

    rs.fields("fieldname")

    This is what I have in my web service so far:

    Dim adpt As New SqlClient.SqlDataAdapter(strSQL, con)
    Dim ds As New DataSet()
    Dim combinedTable As DataTable = ds.Tables.Add("CombinedTable")
    con.Open()
    adpt.Fill(ds, "Combined")
    intRowCount = combinedTable.Rows.Count()
    intMaxID = combinedTable.Rows(intRowCount).Item(0)
    con.Close()
    Return ds

    What I'm doing is trying to get the row count and then use that count as the row reference. I keep coming up with zero although I am returning 100 records. Any help would be appreciated.
    A cynic knows the price of everything but the value of nothing.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    Tennessee
    Posts
    279
    The answer is:

    con.Open()
    adpt.Fill(ds, "Combined")
    intRowCount = ds.Tables("Combined").Rows.Count

    intMaxID = ds.Tables("Combined").Rows(intRowCount - 1).Item("ID")
    con.Close()
    A cynic knows the price of everything but the value of nothing.

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