442
צפיות
צפיות
6
תשובות
תשובות
פעולות חיבור וחיסור בין רשומות
יש לי שתי רשומות שאני רוצה לקבל את תוצאת החיבור שלהם כלמור
אם יש רשומה שבה יש מס' 2 וברשומה הבא יש בה מס' 3 אז תוצאת החיבור
שלהם צריכה להיות 5 משום מה אצלי זה מציג כ 23 להלן הקוד שרשמתי:
servRec.fields("totpip")+servRec.fields("totpip")
6 תשובות
לא יודע איך זה בASP
בס"ד
אבל כנראה שאתה עושה חיבור מחרוזות לא חיבור חשבוני.
בניה צודק.
אם אתה עובד ב VBS, תעשה cInt על הערכים (כדאי שתבדוק קודם isNumeric, שלא תקבל שגיאה בטעות).
אם אתה עובד ב js, אתה יכול פשוט להכפיל את הערכים ב 1.
בכל אופן בדוק איך מוגדרים השדות ב DB. אם הם מוגדרים כמספריים, ב ASP אתה אמור לקבל אותם כמספריים.
אני מקבל הודעת שגיא
משום מה אני מקבל הודעת שגיא זה מה שרשמתי:
For intRec = 1 To servRec.PageSize
If Not servRec.EOF Then
totp=CInt(totp+servRec.fields("totpip"))
totm=CInt(totm+servRec.fields("sumony"))
response.write"<tr>"
response.write"<td bgcolor=#D5EAFF style='width:445; font-size:12; font-family:Arial; text-align:center; cursor:default;'>"& servRec.fields("sumony") &"</td>"
response.write"<td bgcolor=#D5EAFF style='width:445; font-size:12; font-family:Arial; text-align:center; cursor:default;'>"& servRec.fields("totpip") &"</td>"
response.write"<td bgcolor=#D5EAFF style='width:445; font-size:12; font-family:Arial; text-align:center; cursor:default;'>"& servRec.fields("lnam") &"</td>"
response.write"<td bgcolor=#D5EAFF style='width:445; font-size:12; font-family:Arial; text-align:center; cursor:default;'>"& servRec.fields("fnam") &"</td>"
response.write"<td bgcolor=#D5EAFF style='width:40; font-size:12; font-family:Arial; text-align:center; cursor:default;'>"
%>
<a href='del.asp?idbn=<%=servRec.fields("id") %>' target='wshow' onClick="setTimeout('document.location.reload();',1000);"> [ X ] </a></td>
<%
response.write"</tr>"
servRec.MoveNext
intTotalPage=intTotalPage+1
End If
Next
response.write"</table>"
response.write"</div>"
response.write"</td>"
response.write"</tr>"
%>
<div id="restb" style="position:absolute; top:100; left:50; width:150; height:47; border:solid 1 #000000; display:none;">
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td bgcolor=silver width=80 style="font-size:12; font-family:arial; text-align:center; cursor:default; color:#000000;"><%=servRec.RecordCount%></td>
<td bgcolor=gray width=70 style="font-size:12; font-family:arial; text-align:right; cursor:default; color:#FFFFFF;">סה'כ זוגות </td>
</tr>
<tr>
<td bgcolor=silver width=80 style="font-size:12; font-family:arial; text-align:center; cursor:default; color:#000000;"><%=totp%></td>
<td bgcolor=gray width=70 style="font-size:12; font-family:arial; text-align:right; cursor:default; color:#FFFFFF;">סה'כ אנשים </td>
</tr>
<tr>
<td bgcolor=silver width=80 style="font-size:12; font-family:arial; text-align:center; cursor:default; color:#000000;"><%=totm%></td>
<td bgcolor=gray width=70 style="font-size:12; font-family:arial; text-align:right; cursor:default; color:#FFFFFF;">סה'כ כסף </td>
</tr>
</table>
</div>
<%
servRec.Close
Set servRec=Nothing
%>
וזו הודעת השגיא
וזו הודעת השגיא שאני מקבל:
The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.
——————————————————————————–
Please try the following:
Click the Refresh button, or try again later.
Open the 127.0.0.1 home page, and then look for links to the information you want.
HTTP 500.100 – Internal Server Error – ASP error
Internet Information Services
——————————————————————————–
Technical Information (for support personnel)
Error Type:
Microsoft VBScript runtime (0x800A0006)
Overflow: 'CInt'
/wed/show.asp, line 133
Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; DigExt; .NET CLR 1.1.4322)
Page:
GET /wed/show.asp
Time:
יום שלישי 15 נובמבר 2005, 13:52:24
More information:
Microsoft Support
מודה מראש על העזרה.
הבאת יותר מדי קוד…
היו מספיקות השורות של ה cInt.
בכל אופן, נסה ככה:
totp=totp + CInt(servRec("totpip"))
totm=totm + CInt(servRec("sumony"))
תודה זה עבד