Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    3

    Question Unanswered: Can you tell me what's wrong with this code?

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!--#include file="../Connections/users.asp" -->
    <%
    Dim vote
    Dim vote_numRows
    Dim a, b, c, d


    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open "c:/Inetpub/wwwroot/ado/db1.mdb"

    Set vote = Server.CreateObject("ADODB.Recordset")
    vote.ActiveConnection = MM_users_STRING
    vote.Source = "SELECT All Voted, VotedYes FROM vote"
    vote.CursorType = 0
    vote.CursorLocation = 2
    vote.LockType = 1
    vote.Open "Vote", conn

    Set a = vote("All Voted")
    Set b = vote("Voted Yes")
    Set c=a+1 (it give's me an "Exeption occurred error in this line.Why?")
    Set d=b+1

    vote_numRows = 0
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <%
    if Request.Form("Yes")="checked" then
    sql="UPDATE vote SET"
    sql=sql & "All Voted='" & c & "',"
    sql=sql & "Voted Yes='" & d & "',"
    conn.Execute sql

    else
    sql="UPDATE vote SET"
    sql=sql & "All Voted='" & c & "',"
    sql=sql & "Voted Yes='" & b & "',"
    conn.Execute sql

    %>
    </body>
    </html>
    <%
    vote.Close()
    end If
    Set vote = Nothing
    %>

  2. #2
    Join Date
    Mar 2004
    Posts
    6
    Set a = vote("All Voted")

    Set c=a+1

    my guess is that a = ended being a character and you can't mathematically add 1 to a character

    c = "All Voted" + 1

    You should comment out the line of code where there's an error and response.write a, b, c, d to see what values are being held in those variables

  3. #3
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    <<
    Set c=a+1 (it give's me an "Exeption occurred error in this line.Why?")
    >>

    Perhaps change to be more like this (assuming that the variable a really does contain a number and be sure it's sometimes perhaps 0 and never just blank):
    c = CLng(a) + 1
    Last edited by Bullschmidt; 03-12-04 at 02:38.
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

  4. #4
    Join Date
    Mar 2004
    Posts
    3

    Unhappy Still not working

    I checked:
    *the values are numeric
    *Paul's suggestion doesn't change anything - it still gives an Exeption Error

  5. #5
    Join Date
    Mar 2004
    Posts
    3

    Unhappy Fixed it, but there're still errors

    I messed with the code and repaired that mistake, but now it gives me a
    Object required: '[number: 1]' error.
    now what's wrong???

  6. #6
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    <<
    I messed with the code and repaired that mistake, but now it gives me a
    Object required: '[number: 1]' error.
    now what's wrong???
    >>

    I have no idea since you didn't tell us what you changed.
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •