Author |
Topic  |
|
cavalli
Starting Member
Brazil
5 Posts |
Posted - 06 April 2001 : 02:02:00
|
Hi I am developing an aplication that show 15 members from an shopping cart per page. The code is based on members.asp from SNITZ FORUM, but when I run the script I recieve the error:
Microsoft VBScript runtime error '800a000b'
Division by zero
/dados/loja/members.asp, line 48
Anyone can help me ?
Thanks, André Cavalli
|
|
RichardKinser
Snitz Forums Admin
    
USA
16655 Posts |
Posted - 06 April 2001 : 02:29:40
|
What is on that line of members.asp ?
alos what code is above that line? |
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 06 April 2001 : 03:45:04
|
Common reasons include assuming there is a value in a database field when there isn't, ending up with variable / rs("field") giving your error.
You should always code testing for the divisor to be non-zero (or is it the dividend, the bottom part anyway). Divide by zero used to crash computers some years back.
====== Doug G ====== |
 |
|
cavalli
Starting Member
Brazil
5 Posts |
Posted - 08 April 2001 : 01:20:05
|
Hi everybody, thanks for reply. I will put the code for you see if it has an error... Here is the code.
<% mypage = request("whichpage") if mypage = "" then mypage = 1 end if 'mypagesize = request("pagesize") 'if mypagesize = "" then ' mypagesize = 15 'end if
'## Forum_SQL - Get all active topics from last visit set my_Conn = Server.CreateObject("ADODB.Connection") strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/dados/loja/loja.mdb") '## MS Access 2000 using virtual path my_Conn.Open strConnString strSql = "SELECT " & customers & "customers.custid, " & customers & "customers.fname, " & customers & "customers.lname, " & customers & "customers.email, " & costumers & "customers.niver, " & customers & "customers.cpf, " & customers & "customers.address1, " & customers & "customers.city, " & customers & "customers.state, " & customers & "customers.zip, " & customers & "customers.phone, " & customers & "customers.fax " strSql = strSql & " FROM " & customers & "customers " select case Request.QueryString("method") case "nameasc" strSql = strSql & " ORDER BY " & customers & "customers.fname ASC" case "namedesc" strSql = strSql & " ORDER BY " & customers & "customers.fname DESC" case "niverasc" strSql = strSql & " ORDER BY " & customers & "customers.niver ASC, " & customers & "customers.fname ASC" case "niverdesc" strSql = strSql & " ORDER BY " & customers & "customers.niver DESC, " & customers & "customers.fname ASC" case "cidadeasc" strSql = strSql & " ORDER BY " & customers & "customers.city ASC, " & customers & "customers.fname ASC" case "cidadedesc" strSql = strSql & " ORDER BY " & customers & "customers.city DESC, " & customers & "customers.fname ASC" case "estadoasc" strSql = strSql & " ORDER BY " & customers & "customers.state ASC, " & customers & "customers.fname ASC" case "estadodesc" strSql = strSql & " ORDER BY " & customers & "customers.state DESC, " & customers & "customers.fname ASC" end select
'## Forum_SQL - Get the total pagecount strSql2 = "SELECT COUNT(" & customers & "customers.custid) AS PAGECOUNT " strSql2 = strSql2 & " FROM " & customers & "customers " strSql2 = strSql2 & " WHERE " & customers & "customers.fname <> 'fname' " set rsCount = my_Conn.Execute(strSql2)
if not rsCount.eof then maxpages = (rsCount("PAGECOUNT") \ strPageSize ) if rsCount("PAGECOUNT") mod strPageSize <> 0 then maxpages = maxpages + 1 end if maxRecs = cint(strPageSize) * maxPages else maxpages = 0 end if
rsCount.close set rs = Server.CreateObject("ADODB.Recordset") rs.open strSql, my_Conn, 3 if not (rs.EOF or rs.BOF) then rs.movefirst end if
Set rs = Server.CreateObject("ADODB.RecordSet") rs.cachesize=20 rs.open strSql, my_conn, 3
if not (rs.EOF or rs.BOF) then '## No members found in DB rs.movefirst rs.pagesize = strPageSize rs.cacheSize = strPageSize maxPages = cint(rs.pageCount) maxRecs = cint(rs.pageSize) rs.absolutePage = myPage maxpages = cint(rs.pagecount) end if
%> <table width="95%" border="0"> <tr> <td> </td> <td align="right"> <% if maxpages > 1 then %> <table border=0 align="right"> <tr> <td valign="top"><b><font face="Arial" size="<% =strDefaultFontSize %>">Pages:</font></b> <font face="Arial" size="<% =strDefaultFontSize %>"> </font></td> <td valign="top"><font face="Arial" size="<% =strDefaultFontSize %>"><% Call Paging() %></font></td> </tr> </table> <% else %> <% end if %> </td> </tr> </table>
<table border="0" width="95%" cellspacing="0" cellpadding="0" align="center"> <tr> <td bgcolor="<% =strTableBorderColor %>"> <table border="0" width="100%" cellspacing="1" cellpadding="4"> <tr> <td align="center"> </td> <td align="center"><a href="members.asp?method=<% if Request.QueryString("method") = "nameasc" then Response.Write("namedesc") else Response.Write("nameasc") end if %>"><b><font face="Arial" size="2" color="<% =strHeadFontColor %>">Nome</font></b></a></td> <td align="center"><b><font face="Arial" size="2" color="<% =strHeadFontColor %>">Empresa</font></b></td> <td align="center"><b><font face="Arial" size="2" color="<% =strHeadFontColor %>">E-mail</font></b></td> <td align="center"><a href="members.asp?method=<% if Request.QueryString("method") = "niverasc" then Response.Write("niverdesc") else Response.Write("niverasc") end if %>"><b><font face="Arial" size="2" color="<% =strHeadFontColor %>">Data de Aniversário</font></b></a></td> <td align="center"><b><font face="Arial" size="2" color="<% =strHeadFontColor %>">CPF/CNPJ</font></b></td> <td align="center"><b><font face="Arial" size="2" color="<% =strHeadFontColor %>">Endereço</font></b></td> <td align="center"><a href="members.asp?method=<% if Request.QueryString("method") = "cidadeasc" then Response.Write("cidadedesc") else Response.Write("cidadeasc") end if %>"><b><font face="Arial" size="2" color="<% =strHeadFontColor %>">Codade</font></b></a></td> <td align="center"><a href="members.asp?method=<% if Request.QueryString("method") = "estadoasc" then Response.Write("estadodesc") else Response.Write("estadoasc") end if %>"><b><font face="Arial" size="2" color="<% =strHeadFontColor %>">Estado</font></b></a></td> <td align="center"><b><font face="Arial" size="2" color="<% =strHeadFontColor %>">CEP</font></b></td> <td align="center"><b><font face="Arial" size="2" color="<% =strHeadFontColor %>">Telefone</font></b></td> <td align="center"><b><font face="Arial" size="2" color="<% =strHeadFontColor %>">Celular</font></b></td> </tr> <% if rs.EOF or rs.BOF then '## No Members Found in DB %> <tr> <td><b><font face="Arial">No Members Found</font></b></td> </tr> <% else %> <% currMember = 0 %> <% i = 0 howManyRecs = 0 rec = 1 do until rs.Eof or rec = (strPageSize + 1) if i = 1 then CColor = strAltForumCellColor else CColor = strForumCellColor end if %> <tr> <td align=center> <font face="Arial" size="2"> </font> </td> <td><font face="Arial" size="2"> <% =rs("fname") %></font></td> <td align=center nowrap><font face="Arial" size="2" color="<% =strForumFontColor %>"><% =rs("lname") %></font></td> <td align=center><font face="Arial" size="2"><% =rs("email") %> </font></td> <td align=center><font face="Arial" size="2"><% =rs("niver") %> </font></td> <td align=center><font face="Arial" size="2"><% =rs("cpf") %> </font></td> <td align=center><font face="Arial" size="2"><% =rs("address1") %> </font></td> <td align=center><font face="Arial" size="2"><% =rs("city") %> </font></td> <td align=center><font face="Arial" size="2"><% =rs("state") %> </font></td> <td align=center><font face="Arial" size="2"><% =rs("zip") %> </font></td> <td align=center><font face="Arial" size="2"><% =rs("phone") %> </font></td> <td align=center><font face="Arial" size="2"><% =rs("fax") %> </font></td> </tr> <% currMember = rs("id") rs.MoveNext i = i + 1 if i = 2 then i = 0 rec = rec + 1 loop end if %> </table> </td> </tr> <tr> <td colspan="2"> <table border="0" width="100%"> <tr> <td> <% if maxpages > 1 then %> <table border=0> <tr> <td valign="top"><b><font face="Arial" size="<% =strDefaultFontSize %>">Members are <% =maxpages %> Pages Long:</font></b> <font face="Arial" size="<% =strDefaultFontSize %>"> </font></td> <td valign="top"><font face="Arial" size="<% =strDefaultFontSize %>"><% Call Paging() %></font></td> </tr> </table> <% else %> <% end if %> </td> </tr> </table> </td> </tr> </table>
<% sub Paging() if maxpages > 1 then if Request.QueryString("whichpage") = "" then sPageNumber = 1 else sPageNumber = Request.QueryString("whichpage") end if if Request.QueryString("method") = "" then sMethod = "postsdesc" else sMethod = Request.QueryString("method") end if sScriptName = Request.ServerVariables("script_name") Response.Write("<table border=0 width=100% cellspacing=0 cellpadding=1 align=top><tr>") for counter = 1 to maxpages if counter <> cint(sPageNumber) then sNum = "<td align=right bgcolor=" & strPageBGColor & "><font face=" & strDefaultFontFace & " size=" & strDefaultFontSize & ">" & " " & widenum(counter) & "<a href=""" & sScriptName sNum = sNum & "?whichpage=" & counter 'sNum = sNum & "&pagesize=" & mypagesize sNum = sNum & "&method=" & sMethod sNum = sNum & """>" & counter & "</a></font></td>" Response.Write sNum else Response.Write("<td align=right bgcolor=" & strPageBGColor & "><font face=" & strDefaultFontFace & " size=" & strDefaultFontSize & ">" & " " & widenum(counter) & "<b>" & counter & "</b></font></td>") end if if counter mod strPageNumberSize = 0 then Response.Write("</tr><tr>") end if next Response.Write("</tr></table>") end if end sub %>
The error occurs here:
if not rsCount.eof then maxpages = (rsCount("PAGECOUNT") \ strPageSize )
Thanks for all help. André Cavalli
Edited by - cavalli on 08 April 2001 01:24:42 |
 |
|
RichardKinser
Snitz Forums Admin
    
USA
16655 Posts |
Posted - 08 April 2001 : 02:31:47
|
you probably don't have strPageSize defined.
If you took this code from the members.asp page of the forum, strPageSize is defined via the Admin Options. So you'll need to define strPageSize at the top of your code. |
 |
|
cavalli
Starting Member
Brazil
5 Posts |
Posted - 09 April 2001 : 15:33:48
|
Hi Richard, thanks for reply. The strPageSize wasn't defined. Now I defined strPageSize=3 and now the error is other. I think this is the last one, I hope :) When I run the members.asp I receiv that:
Pages: Microsoft VBScript runtime error '800a000d' Type mismatch: 'widenum'
/dados/loja/members.asp, line 217 That line is:
Response.Write("<td align=right bgcolor=" & strPageBGColor & "><font face=" & strDefaultFontFace & " size=" & strDefaultFontSize & ">" & " " & widenum(counter) & "<b>" & counter & "</b></font></td>")
Thanks for all help André Cavalli
|
 |
|
|
Topic  |
|