MoveFirst, MoveLast

Discussion in 'ASP .Net' started by Marcin Zmyslowski, Aug 18, 2005.

  1. Hello!

    I use data.read and data.getValue(Id_column) to get the value of
    specified column. Unfortunately there are some differences between
    VBScript and Visual Basic (MS Access) and I cannot move to the first and
    last record of data. I searched archieves and I couldn`t find any
    example how to do it. I use MS SQL Server 2000 as a server and I wrote a
    sql query where I used data.reader. Could you give me the example how to
    modify the code to have movefirst and movelast possibilites?

    Thank you in advance
    Marcin

    *** Sent via Developersdex http://www.developersdex.com ***
    Marcin Zmyslowski, Aug 18, 2005
    #1
    1. Advertising

  2. you can't use a datareader to do that, as it's a forward only data
    construct. If you wish to navigate, use the dataset. You'll need to give it
    a dataview, and then do a check on the rows, and read the individual row i.e


    Dim cnNorthwind As SqlConnection = new SqlConnection("Persist
    Security Info=False;Integrated
    Security=SSPI;database=northwind;server=mySQLServer")
    ' Create a SqlDataAdapter for the Suppliers table.
    Dim adpSuppliers As SqlDataAdapter = new SqlDataAdapter()
    ' A table mapping tells the adapter what to call the table.
    adpSuppliers.TableMappings.Add("Table", "Suppliers")
    cnNorthwind.Open()
    Dim cmdSuppliers As SqlCommand = _
    new SqlCommand("SELECT * FROM Suppliers", cnNorthwind)
    cmdSuppliers.CommandType = CommandType.Text

    adpSuppliers.SelectCommand = cmdSuppliers

    ds = New DataSet("Customers")
    adpSuppliers.Fill(ds)
    dim myDataview as dataview=new dataview(ds.tables("suppliers"))
    'optionally use mydataview.sort to sort i.e. mydataview.sort="supplierID"
    dim intLast as integer=myDataView.count-1
    'movelast
    console.write (myDataView(intLast)("somecolumn").tostring
    'movefirst
    console.write (myDataView(0)("somecolumn").tostring

    "Marcin Zmyslowski" <> wrote in message
    news:...
    Hello!

    I use data.read and data.getValue(Id_column) to get the value of
    specified column. Unfortunately there are some differences between
    VBScript and Visual Basic (MS Access) and I cannot move to the first and
    last record of data. I searched archieves and I couldn`t find any
    example how to do it. I use MS SQL Server 2000 as a server and I wrote a
    sql query where I used data.reader. Could you give me the example how to
    modify the code to have movefirst and movelast possibilites?

    Thank you in advance
    Marcin

    *** Sent via Developersdex http://www.developersdex.com ***
    Cathal Connolly [VB MVP], Aug 18, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RHVuY2Fu?=
    Replies:
    3
    Views:
    446
    =?Utf-8?B?RHVuY2Fu?=
    Mar 31, 2006
  2. shank
    Replies:
    5
    Views:
    119
    Chris Barber
    Oct 31, 2003
  3. joeandtel

    Can't use moveLast() function

    joeandtel, Feb 20, 2004, in forum: ASP General
    Replies:
    1
    Views:
    101
    Ray at
    Feb 20, 2004
  4. tony wong

    Recordset MoveLast

    tony wong, Aug 14, 2005, in forum: ASP General
    Replies:
    3
    Views:
    143
    Aaron Bertrand [SQL Server MVP]
    Aug 15, 2005
  5. le0

    RcrdSet.MoveLast

    le0, Aug 24, 2006, in forum: ASP General
    Replies:
    2
    Views:
    123
    Bob Barrows [MVP]
    Aug 24, 2006
Loading...

Share This Page