locked
strange problem with records from an access db RRS feed

  • Question

  • User651828378 posted

    Hi.

    I have to pages
    - my db
    - first page
    - folder
      - sec page

    If i use this on my first page, Then i get resord id 1

            Dim strSQL As String = ""
    
            strSQL = "" & _
            "SELECT * " & _
            "FROM shop_histo " & _
            "WHERE shophis_id = 1"
    
            Using connection As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnStr").ConnectionString)
                Using command As OleDbCommand = New OleDbCommand(strSQL, connection)
                    command.Connection.Open()
                    Using reader As OleDbDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
                        If reader.HasRows Then
                            reader.Read()
                            Response.Write("<div class=""product-view""><div class=""page-title""><h1>" & reader("shophis_title") & "</h1></div><div class=""tabs-block-2""><div class=""box-collateral box-up-sell"">")
                            Response.Write(reader("shophis_text"))
                            Response.Write("</div></div></div>")
                        End If
                    End Using
                End Using
            End Using



    But if i then use it on the sec page, then i can't get record 1 and if i use this code, i get all other records then record 1, the first record in db

            Dim strSQL As String = ""
    
            strSQL = "" & _
            "SELECT shophis_id, shophis_title, shophis_text, shophis_on " & _
            "FROM shop_histo " & _
            "WHERE shophis_on = yes"
    
            Using connection As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnStr").ConnectionString)
                Using command As OleDbCommand = New OleDbCommand(strSQL, connection)
                    command.Connection.Open()
                    Using reader As OleDbDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
                        If reader.HasRows Then
                            reader.Read()
                            Do While reader.Read
                                Response.Write("<tr>")
                                Response.Write("<td></td>")
                                Response.Write("<td>" & reader("shophis_title") & "</td>")
                                Response.Write("<td>Aktiv</td><td>20.03.2010</td><td>John Doe</td>")
                                Response.Write("<td class=""delete""><a href="""">Delete</a></td>")
                                Response.Write("</tr>")
                            Loop
                        End If
    
                    End Using
                End Using
            End Using



    Why this strange problem !?

    Sunday, June 17, 2012 6:40 AM

Answers

  • User651828378 posted

    I deleted reader.Read() Then it works.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 17, 2012 9:15 AM

All replies

  • User-661350001 posted

    In the first page where clause is different from the second page "WHERE shophis_on = yes" so the result is different which is obviously meaningful

    Sunday, June 17, 2012 7:25 AM
  • User651828378 posted

    Hi thx. plz Read again, as i pointet out, if i use the first code on page 2 aswell then i cant get the record 1, and if i use the code 2 on page 2 (and record 1 is also yes in shophis_on) then i get all records, but not record 1 again, so No its not meaningful....

    Sunday, June 17, 2012 7:43 AM
  • User651828378 posted

    I deleted reader.Read() Then it works.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 17, 2012 9:15 AM