Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Try Your Luck

Try Your Luck

Scheduled Pinned Locked Moved Visual Basic
databasequestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Karma31251
    wrote on last edited by
    #1

    Ok, so, I have a VB2005 Program linked to a database. I also have a datagrid on the form that displays a certain table in the database. Now, randomly the datagrid will rearrange the sort order for no apparent reason. I use PKeys that run off AutoNumbers, so you'd think it would not be that hard and 99.9 % of the time the code will load the correct order, 1,2,3,4,5,6,7,etc... But once in a while it will load up not just backwards or something but just all out of order, 2,5,4,1,6,3,7, etc... The fill code looks like this : "Me.TblFruitTableAdapter.Fill(Me.DbScreenDataSet.tblFruit, DatePro)" Its pretty much computer generated except for i added in a variable for the Date of Production so that when the program loads it only grabs the records for that day, but the records get put in, in order so that day 1 hour 1 is record 1 of the day. Can anyone explain why 99.9 % of the time it loads the records correctly but once in awhile it will load them distorted?

    C 1 Reply Last reply
    0
    • K Karma31251

      Ok, so, I have a VB2005 Program linked to a database. I also have a datagrid on the form that displays a certain table in the database. Now, randomly the datagrid will rearrange the sort order for no apparent reason. I use PKeys that run off AutoNumbers, so you'd think it would not be that hard and 99.9 % of the time the code will load the correct order, 1,2,3,4,5,6,7,etc... But once in a while it will load up not just backwards or something but just all out of order, 2,5,4,1,6,3,7, etc... The fill code looks like this : "Me.TblFruitTableAdapter.Fill(Me.DbScreenDataSet.tblFruit, DatePro)" Its pretty much computer generated except for i added in a variable for the Date of Production so that when the program loads it only grabs the records for that day, but the records get put in, in order so that day 1 hour 1 is record 1 of the day. Can anyone explain why 99.9 % of the time it loads the records correctly but once in awhile it will load them distorted?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Does your SQL have an order by statement ?

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      K 1 Reply Last reply
      0
      • C Christian Graus

        Does your SQL have an order by statement ?

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        K Offline
        K Offline
        Karma31251
        wrote on last edited by
        #3

        I'm sorry I forgot to mention that i am using MS Access for my database purposes.

        C D 2 Replies Last reply
        0
        • K Karma31251

          I'm sorry I forgot to mention that i am using MS Access for my database purposes.

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          OK, so build your SQL on each keypress, and filter your data direct from the DB.

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          1 Reply Last reply
          0
          • K Karma31251

            I'm sorry I forgot to mention that i am using MS Access for my database purposes.

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            An SQL query is not guaranteed to return records in a specific order unless told to with an ORDER BY clause in the SELECT statement.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups