1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

why not UPDATE all instead of 10 at a time?

Discussion in 'C#' started by gilgalbiblewheel, Apr 21, 2005.

  1. #1
    THinking that the reasone why it's not UPDATING all was because the the page holds 10 records at a time right? I tried blocking all the codes which have to do with pageing but it's not working. Can you show me what I missed (if that's the reason why it cannot UPDATE all at once)?
    <% Option Explicit 
    
    ' ADO constants used in this page
    Const adOpenForwardOnly = 0
    Const adLockReadOnly = 1
    Const adCmdTableDirect = &H0200
    Const adUseClient = 3
    %>
    <html>
    <head>
      <style>
      body { font-family : Verdana; font-size : 8pt; }
      a { font-family : Verdana; font-size : 8pt; text-decoration : none; }
      </style>
    </head>
    
    <body>
    <%
      Dim connStr
        connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("hebrewbible.mdb")
    
            Dim ans
            Dim i
            Dim rs
            Dim SQL
            Dim TheString, ArrayTemp, NumberOfWords, Word
    
    function getKeyValue_h(chr)
      //A select statement is more efficient for this
      select case chr
       case "a"
        getKeyValue_h = 1 
       case "b"  
        getKeyValue_h = 2 
       case "g"
        getKeyValue_h = 3 
       case "d"
        getKeyValue_h = 4 
       case "h"
        getKeyValue_h = 5 
       case "w"
        getKeyValue_h = 6 
       case "z"
        getKeyValue_h = 7 
       case "x"
        getKeyValue_h = 8 
       case "j"
        getKeyValue_h = 9 
       case "y"
        getKeyValue_h = 10 
       case "k","$"
        getKeyValue_h = 20 
       case "l"
        getKeyValue_h = 30 
       case "m","~"
        getKeyValue_h = 40 
       case "n","!"
        getKeyValue_h = 50 
       case "s"
        getKeyValue_h = 60 
       case "["
        getKeyValue_h = 70 
       case "p","@"
        getKeyValue_h = 80 
       case "c","#"
        getKeyValue_h = 90 
       case "q"
        getKeyValue_h = 100 
       case "r"
        getKeyValue_h = 200
       case "f","v"
        getKeyValue_h = 300 
       case "t"
        getKeyValue_h = 400
       case else
        getKeyValue_h = 0
      end select
    end function 
    
    function computeValue(str)
      ans = 0
      for i = 0 to len(str)
        ans = ans + getKeyValue_h(mid(str,i+1,1))
      next
      computeValue = ans 
    end function
    
    SQL = "SELECT * from hebrewbibletable"
    SQL = SQL & " ORDER by id ASC "  
    
        Set rs = Server.CreateObject("ADODB.Recordset")
        
    '    rs.PageSize = 10
    '    rs.CacheSize = 5
    '    rs.CursorLocation = adUseClient
    
    
    
        rs.Open SQL, connStr, adOpenForwardOnly, adLockReadOnly, adCmdTableDirect
        
        
    '    If Len(Request("pagenum")) = 0  Then
    'a        rs.AbsolutePage = 1
    '      Else
    '        If CInt(Request("pagenum")) <= rs.PageCount Then
    '            rs.AbsolutePage = Request("pagenum")
    '          Else
    '            rs.AbsolutePage = 1
    '        End If
    '    End If
        
    '    Dim abspage, pagecnt
    '      abspage = rs.AbsolutePage
    '      pagecnt = rs.PageCount
        
        If Not rs.EOF Then
    '      Response.Write "PageCount : " & rs.PageCount & "<br>" & vbcrlf
    '      Response.Write "Absolute Page : " & rs.AbsolutePage & "<br>" & vbcrlf
          
            Response.Write "Total number of records : " & rs.RecordCount & "<br><br>" & vbcrlf
            
            Dim fldF, intRec%>
    <form method="post" action="pageing2update.asp">
    <%'<form method="post" action="pageing4.asp">
    '<form method="post" action="pageing2update3.asp">
            
            Response.Write "<table border=1 align=center cellpadding=3 cellspacing=0><thead><tr>"
            For Each fldF in rs.Fields
              Response.Write "<td>" & fldF.Name & "</td>"
            Next
            Response.Write "<td><input type=""submit"" value=""Add New""></td></tr></thead><tbody>"
            For intRec=1 To rs.PageSize
              If Not rs.EOF Then
                Response.Write "<tr>"
                For Each fldF in rs.Fields
                  Response.Write "<td>" & fldF.Value & "</td>"
                Next%>
    <td><%=rs("id")%>
    <input type="hidden" name="id_<%=intRec%>"
     value="<%=rs.Fields("id").Value%>">
    <textarea name="gemetria_<%=intRec%>"  
    id="gemetria_<%=intRec%>">
    <%'Dim TheString, ArrayTemp, NumberOfWords, Word
      TheString = rs("text_data")
      ArrayTemp = split(TheString, " ")
      NumberOfWords = UBound(ArrayTemp) + 1
    'dont need  Response.Write "<P>The String is: " & TheString
    '   Response.Write "<P><i>Number of words:</i> " & NumberOfWords
    '        Response.Write "<BR>Total=" & computeValue(TheString)  
    'dont need  Response.Write "<P>Here are the words which compose that string: "
      For Each Word In ArrayTemp
    '  Response.Write "<BR><font size=""5"" face=""BSTHebrew"">" & word & "</font>="
      response.write computeValue(word)
           response.write "&nbsp;+&nbsp;"
      next
    
    %>
    </textarea></td>
    <%
                Response.Write "<tr>"
                rs.MoveNext
              End If
            Next
            Response.Write "</tbody></table><p>"
            
            ' Now showing first, next, back, last buttons.
    '        Response.Write "<div align=""center"">" & vbcrlf
    '        Response.Write "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?pagenum=1"">First Page</a>"
    '        Response.Write "&nbsp;|&nbsp;"
            
    '        If abspage = 1 Then
    '        Response.Write "<span style=""color:silver;"">Previous Page</span>"
    '        Else
    '        Response.Write "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?pagenum=" & abspage - 1 & """>Previous Page</a>"
    '        End If
    '                Response.Write "&nbsp;|&nbsp;"
            
    '        If abspage < pagecnt Then
    '        Response.Write "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?pagenum=" & abspage + 1 & """>Next Page</a>"
    '        Else
    '        Response.Write "<span style=""color:silver;"">Next Page</span>"
    '        End If
    '        Response.Write "&nbsp;|&nbsp;"
    '        Response.Write "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?pagenum=" & pagecnt & """>Last Page</a>"
    '        Response.Write "</div>" & vbcrlf%>
    </form>
    <%        
        Else
          Response.Write "No records found!"
        End If
                
        rs.Close
        Set rs = Nothing
    %>
    </body>
    </html>
    Code (markup):

     
    gilgalbiblewheel, Apr 21, 2005 IP
  2. lovethecoast

    lovethecoast Peon

    Messages:
    33
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I gave your code about a 5 minute overview. First, to get help, you *really* need to better format your code. Mixing so much asp and html code only slows things down. (Disclaimer before someone else points it out: Not significantly, for sure -- but there is a decrease in performance.) It also makes your code *very* hard to read. Put all of your asp code in routines and leave html out of them to make reading your code (which translates to maintaining your code) easier.

    Now to your question -- it's impossible to tell why it's not updating all records, because you didn't include your update statement. The code above only includes SELECT statements. You reference pageing2update.asp as the result page for your form, but you don't include the code in the sample above.
     
    lovethecoast, Apr 30, 2005 IP