If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Can you tell me what's wrong with this code?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-11-04, 15:16
colors colors is offline
Registered User
 
Join Date: Mar 2004
Posts: 3
Question 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
%>
Reply With Quote
  #2 (permalink)  
Old 03-11-04, 19:16
w1n78 w1n78 is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 03-12-04, 01:35
Bullschmidt Bullschmidt is offline
Guru
 
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
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips

Last edited by Bullschmidt; 03-12-04 at 01:38.
Reply With Quote
  #4 (permalink)  
Old 03-12-04, 11:31
colors colors is offline
Registered User
 
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
Reply With Quote
  #5 (permalink)  
Old 03-12-04, 12:45
colors colors is offline
Registered User
 
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???
Reply With Quote
  #6 (permalink)  
Old 03-12-04, 16:43
Bullschmidt Bullschmidt is offline
Guru
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On