RS.movefirst

I am trying to access the first record of a table by using rs.movefirst. However, the value that is being returned is not the first in the table. I also tried to use rs.movelast and the value returned was not the last in the table.
Any Ideas?


Thanks,
Matt

Comments

  • : I am trying to access the first record of a table by using
    : rs.movefirst. However, the value that is being returned is not the
    : first in the table. I also tried to use rs.movelast and the value
    : returned was not the last in the table.
    : Any Ideas?
    :
    :
    : Thanks,
    : Matt
    :

    Sort the table first?


    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • Is there a limit to the number of entries you can have in a table? The rs.movefirst works fine until i get a lot of entries in the table.
  • : Is there a limit to the number of entries you can have in a table?
    : The rs.movefirst works fine until i get a lot of entries in the
    : table.
    :

    I wouldn't know. There is always a limit, but I'd say it's quite big (bigger than you are at). Perhaps look at the documentation for the component you are using if there are any limits.
    At what number of entries are you noticing a problem?

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • Well it worked fine until i got about 56,000 entries. However, i could possibly end up having over a million entries

    Thanks,
    Matt
  • seancampbellseancampbell Pennsylvania, USA
    I'm no DB Expert, but that sounds a bit excessive for displaying data to a user, is there anyway to cut back on the amount of data your querying? Possibly send a more specific SQL query to the DB?

    I will keep researching the Recordset, but so far I have not found anything on this issue online.

    -sc
  • : I'm no DB Expert, but that sounds a bit excessive for displaying
    : data to a user, is there anyway to cut back on the amount of data
    : your querying? Possibly send a more specific SQL query to the DB?
    :
    : I will keep researching the Recordset, but so far I have not found
    : anything on this issue online.
    :
    : -sc

    Well I am pulling data from a plc and logging it to an access database. They want it to read data 10 times a second and after. After a week the database table will most likely be way over a million. Therefore, i am trying to create a vb program where i can create a new table then take every entry with a certain day and place in a new table.
  • seancampbellseancampbell Pennsylvania, USA
    Well, I was just thinking, I wrote software a couple months back for my job where I take data from PLCs and hold it in a data table, I am grabbing records well beyond a million records at a time... but I wrote a custom object to handle moving through the data, so I have not come across those short comings.

    What I read was that the VB.Net recordset has an issue with movefirst and movelast when there is a large amount of data:

    http://www.vb-helper.com/bug_dao_movefirst_movelast.html

    This guy suggested adding a Application.DoEvents to the program code before the movefirst event. Try this, if it doesn't work, we can try something else to get around it. I don't think the amount of data is a problem, just the object your holding it is having problems handling it.

    -Sean C
  • I still cant get it to work correctly. Any Ideas?

    Thanks a lot for your help.

  • seancampbellseancampbell Pennsylvania, USA
    It's going to be a day before I get a chance to look into the problem any more or try to develop a workaround, if you don't mind waiting till tomorrow after noon (around 1 or 2 est) then I might have something. Meenwhile, can you post the code that you use to gather data from the database, include everything that is used to connect (but enter in false data for IP Address, UserName, and Password on the databases your connecting to for security sake)

    Maybe it is something simple in the code your using.

    Be sure to post it in code brackets (code) and (/code) with ] and [ instead of ) and (

    Thanks!
  • That is fine.
    Thank you very much for your help.


    Dim dboriginal As DAO.Database
    Dim rs As DAO.Recordset
    Dim dblogger As DAO.Database
    Dim tbllogrecords As DAO.TableDef
    Dim DateAndtime As DateTime
    Dim calendartime As DateTime
    Dim current As Integer
    Dim position As Integer
    Dim thrust As Integer
    Dim speed As Integer
    Dim rs2 As DAO.Recordset
    Dim index As Integer


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    dboriginal = DAODBEngine_definst.OpenDatabase("C:")
    rs = dboriginal.OpenRecordset("Table3")


    End Sub




    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

    dblogger = DAODBEngine_definst.OpenDatabase("C:")
    tbllogrecords = dblogger.CreateTableDef(Calendar.SelectionStart)

    With tbllogrecords
    .Fields.Append(.CreateField("Tag1", DAO.DataTypeEnum.dbInteger))
    .Fields.Append(.CreateField("Tag2", DAO.DataTypeEnum.dbInteger))
    .Fields.Append(.CreateField("Tag3", DAO.DataTypeEnum.dbInteger))
    .Fields.Append(.CreateField("Tag4", DAO.DataTypeEnum.dbInteger))
    .Fields.Append(.CreateField("DateTime", DAO.DataTypeEnum.dbDate))

    End With

    dblogger.TableDefs.Append(tbllogrecords)
    rs2 = dblogger.OpenRecordset(Calendar.SelectionStart)

    End Sub



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


    rs.MoveFirst()


    While Not (rs.EOF)
    DateAndtime = (rs.Fields("DateAndTime").Value)
    index = (rs.Fields("BID").Value)
    calendartime = Calendar.SelectionStart



    If DateAndtime.Date = calendartime Then


    speed = (rs.Fields("TAGS_TAG1_Value").Value)
    thrust = (rs.Fields("TAGS_TAG2_Value").Value)
    position = (rs.Fields("TAGS_TAG3_Value").Value)
    current = (rs.Fields("TAGS_TAG4_Value").Value)


    End If
    rs.MoveNext()
    On Error Resume Next

    End While
    End Sub
    End Class





  • seancampbellseancampbell Pennsylvania, USA
    Is Button1 the code that isn't moving to the first record?
  • : Is Button1 the code that isn't moving to the first record?


    Yes

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories