Results 1 to 3 of 3

Thread: (Resolved) Allways get the last record in the database

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    (Resolved) Allways get the last record in the database

    How do I ensure I allways get the last record in the database? While just using a simple Select Statement it seems to do it by default but I need to make sure it does everytime.
    Code:
            Dim cnn As New OleDbConnection
            Dim cmd As New OleDbCommand
            Dim dr As OleDbDataReader
            cnn.ConnectionString = _
                My.Settings.Coupon_BarcodeConnectionString
            cmd = cnn.CreateCommand
            cmd.CommandText = "SELECT MarketingPiece, [Number] " & _
                "FROM tblMarketingPiece "
            Try
                cnn.Open()
                dr = cmd.ExecuteReader
                While dr.Read()
                    lblMPN.Text = CStr(dr("MarketingPiece"))
                    lblCN.Text = CStr(dr("Number"))
                End While
                dr.Close()
                cnn.Close()
            Catch ex As Exception
                MsgBox("Error: " & ex.Message)
                Exit Sub
            End Try
    Last edited by FastEddie; Nov 13th, 2006 at 01:24 PM.

  2. #2
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Cool Re: Allways get the last record in the database

    Use the SQL command: ORDER BY
    ~Peter


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    Re: Allways get the last record in the database

    OK that was an embarrassingly simple solution. For some reason I have a VB.Net tendency to make things a lot more complicated then they need to be.

    Thanks

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