Avatar billede peterpeter Seniormester
10. maj 2006 - 23:12 Der er 5 kommentarer og
1 løsning

Database lukker forkert

Hej Alle

Denne fil anvendes på vores hjemmeside, men jeg har fået at vide, at grunden til, at der ofte er fejl, skyldes - at der åbnes en database-forbindelse, men at den ikke lukkes korrekt !!

Er der nogen der kan finde denne fejl og rette den ???

Tusind Tak

....og fortsat god aften ;-)

<%
'###################################################
'# Setup
'###################################################
' // Virtuel Path. (Where the files are located)
'PollFilePath="poll/"

PollFilePath="udvidelser/newsandpoll/poll/"
'PollFilePath="http://www.asgi.dk/udvidelser/newsandpoll/poll/"





' // Admin Password
pollAdminModePassword = "Admin"

'Do NOT change the next line
if request("AdminMode")=pollAdminModePassword then PollFilePath=""

'pollDBLocation. Where the database is located
pollDBLocation=server.mappath(PollFilePath&"../../../db/poll.mdb")

' // PollDebug Mode.
' // if true  = Show Error Msg if any Errors. And don't set the cookie date to now + 356days
' // Notice that there is very limited errorhandling.
pollDebug=false

' ####################
' ## Look and feel  ##
' ####################
' // pollBgImage : Used for background color.
pollBgImage = "474971.gif"

' // pollGraphImage : Used for graph bars.
pollGraphImage = "215D84.gif"

' // pollLinesImage : Used for thin lines.
pollLinesImage = "215D84.gif"

' // pollLinesEnabled : Show thin lines or not. Set to true/false.
pollLinesEnabled = true

' // pollFont : Used for text
pollFont = "<font face=""Verdana"" color=""#000000"" size=""1"">"

' // pollHeading : Heading for the poll.
' // Use a image to make it look nice, otherwise uncomment the other line and change the text and/or font
'pollHeading = "<img src="""&PollFilePath&"images/poll_text.gif"">"
pollHeading = "<u><b><font color=""#FFFFFF"" face=""Verdana"" size=""2"">ASGI afstemning</font></b></u>"

'Should the "Total votes" text be shown to users. Set to true or false
pollShowTotalVotes = true

'#####################################################################
'## Text used in script. Change this to your own words/Language    ##
'#####################################################################
pollTxtTotalVotes="Stemmer ialt"

'###################################################
'# Start
'###################################################
dim pollDB,pollRS,pollConstr
dim QID,sQuestion,ShowResultflag

set pollDB=server.createobject("ADODB.Connection")
set pollRS=server.createobject("ADODB.Recordset")
pollConstr = "Provider=MICROSOFT.JET.OLEDB.4.0; Data Source="&pollDBLocation

' // Get active QID and Question from database Question //
FinPollOpenDB()
if request("QID")<>"" then
    QID=request("QID")
    pollRS.open "select * from Questions where QID="&cstr(QID),pollDB,1,2
else
    pollRS.open "select * from Questions where Active=1",pollDB,1,2
end if
if not (pollRS.bof and pollRS.eof) then
    if QID="" then
        QID=pollRS("QID")
    end if
    sQuestion=pollRS("Question")
else
    call DBProcessError("Error : Could not find active poll")
end if
pollRS.close
pollDB.close

'Get the cookie
cookieContent = request.cookies("FinPol" & cstr(QID)&sQuestion)

' // See what we should do
if (cookieContent<>"" OR request("AdminMode")=pollAdminModePassword) then
    'Cookie is set = vote has already been cast OR Admin mode
    'So show the result
    call ShowResult()
elseif (cookieContent="" and request.form("finPollOption")<>"") then
    'Vote has been cast and cookie is empty
    call CastVote()
else
    'Show the poll
    call ShowPoll()
end if

' // Cleanup
set pollRS=nothing
set pollDB=nothing

' // The End

'############################################
'# CastVote()
'# Update database with vote and set cookie
'############################################
function CastVote()
    answer=request.form("finPollOption")
    FinPollOpenDB()
    pollRS.open "select * from Poll where QID="&cstr(QID),pollDB,3,3,1
    if not (pollRS.bof and pollRS.eof) then  '// The poll ID is OK //
        'Update database
        pollRS.find ("AnID = "+cstr(answer))
        pollRS("Answer")=pollRS("Answer")+1
        pollRS.update
        '// set a cookie for this poll //
        '// first clear the response object
        response.clear
        response.cookies("FinPol" & cstr(QID)&sQuestion)=Answer
        if pollDebug<>true then
            response.cookies("FinPol" & cstr(QID)&sQuestion).expires=Date + 365
        end if
    else
        call DBProcessError("A poll with ID No."+cstr(QID)+" could not been found.")
    end if
    pollRS.close
    pollDB.close
    'Cleanup since we are doing a redirect
    set pollRS=nothing
    set pollDB=nothing

    '// Redirect the user using ?prd=1 so Netscape don't throw up a object moved error//
    Response.redirect(Request.ServerVariables("SCRIPT_NAME")&"?prd=1&"&request("QueryStringBackup"))
end function

'############################################
'# ShowPoll()
'# Show the poll
'############################################
function ShowPoll()
    FinPollOpenDB()
    pollRS.open "select * from Poll where QID="+cstr(QID)+" order by AnID",pollDB,1,1
    if not (pollRS.bof and pollRS.eof) then
    %>
    <table border="0" cellspacing="0" width="250">
    <tr>
        <td width="100%" background="<%=PollFilePath%>images/<%=pollBgImage%>"><form method="POST" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
        <input type="hidden" value="<%=cstr(QID)%>" name="fQID">
        <input type="hidden" value="<%=Request.QueryString%>" name="QueryStringBackup">
        <table border="0" cellspacing="0" width="250" background="<%=PollFilePath%>images/ffffff.gif">
        <tr>
            <td colspan="3" background="<%=PollFilePath%>images/<%=pollBgImage%>" width="250" align="center"><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=3><br><%=pollHeading%><br><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=3></td>
        </tr>
        <tr>
            <td width="4" valign="top" align="left">&nbsp;</td>
            <td valign="top" align="left" colspan="2" width="246"><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=3><b><%=pollFont%><br><%=sQuestion%><br></font></b><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=3></td>
        </tr>
<% if (pollLinesEnabled=true) then%>
        <tr>
            <td width="250" valign="top" align="center" colspan="3"><img src="<%=PollFilePath%>images/<%=pollLinesImage%>" height=1 width=95%></td>
        </tr>
<% end if%>
    <%
        while not pollRS.eof
            i=i+1
    %>
        <tr>
            <td width="4" valign="top" align="left">&nbsp;</td>
            <td width="12" valign="top" align="left"><input type="radio" value="<%=cstr(i)%>" name="finPollOption"></td>
            <td valign="top" align="left" width="124"><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=3><%=pollFont%><br>
                  <%=pollRS("AnswerText")%></font></td>
        </tr>
    <%
            pollRS.movenext
        wend
    %>
        <tr>
            <td width="250" valign="top" align="left" colspan="3"><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=1></td>
        </tr>
<% if (pollLinesEnabled=true) then%>
        <tr>
            <td width="250" valign="top" align="center" colspan="3"><img src="<%=PollFilePath%>images/<%=pollLinesImage%>" height=1 width=95%></td>
        </tr>
<% end if%>
        <tr>
            <td width="4" valign="top" align="left">&nbsp;</td>
            <td width="12" valign="top" align="left">&nbsp;</td>
            <td valign="top" align="right"><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=1><br><input type="submit" value="Stem" name="Submit" style="font-family: Verdana; font-size: 8pt; font-weight: bold"><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=10><br>
            <img src="<%=PollFilePath%>images/spacer.gif" height=5 width=1></td>
        </tr>
        </form>
        </table>
        </td>
    </tr>
    </table>
    <%
    end if
    pollRS.close
    pollDB.close
end function

'############################################
'# ShowResult()
'# Show the poll
'############################################
function ShowResult()
FinPollOpenDB()
pollRS.open "select * from Poll where QID="+cstr(QID),pollDB,1,1,1
if not (pollRS.bof and pollRS.eof) then
    set rsTotal=server.createobject("ADODB.Recordset")
    rsTotal.open "Select sum (Answer) from Poll where QID="+cstr(QID), pollDB, 1,1,1
    total=rsTotal(0)
    rsTotal.close
    set rsTotal=nothing
    i=0
    pollRS.movefirst
%>
<table border="0" cellspacing="0" width="250">
<tr>
    <td width="100%" background="<%=PollFilePath%>images/<%=pollBgImage%>"><form method="POST" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
    <input type="hidden" value="<%=cstr(QID)%>" name="fQID">
    <table border="0" cellspacing="0" width="250" background="<%=PollFilePath%>images/ffffff.gif">
    <tr>
        <td colspan="3" background="<%=PollFilePath%>images/<%=pollBgImage%>" width="250" align="center"><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=3><br><%=pollHeading%><br><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=3></td>
    </tr>
    <tr>
        <td width="4" valign="top" align="left">&nbsp;</td>
        <td valign="top" align="left" colspan="2" width="246"><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=3><b><%=pollFont%><br><%=sQuestion%><br></font></b><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=3></td>
    </tr>
<% if (pollLinesEnabled=true) then%>
        <tr>
            <td width="250" valign="top" align="center" colspan="3"><img src="<%=PollFilePath%>images/<%=pollLinesImage%>" height=1 width=95%></td>
        </tr>
<% end if%>
<%
while not pollRS.eof
  i=i+1
%>
    <tr>
        <td width="4" valign="top" align="left"><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=4></td>
        <td width="6" valign="top" align="left"><%=pollFont%>·</font></td>
        <td width="240" valign="top" align="left"><%=pollFont%>
        <b><%=pollRS("AnswerText")%></b><br><%=calculate(pollRS("Answer"),Total)%>&nbsp;<%if ToTal<>0 then Response.write(formatpercent(pollRS("Answer")/Total,0))%>
        <%
        if request("AdminMode")=pollAdminModePassword then
            response.write("<br>"&cstr(pollRS("Answer"))& " Votes")
        end if
        TotalVotes=TotalVotes+cInt(pollRS("Answer"))
        %>
        </font>
        </td>
    </tr>
<%
  pollRS.movenext
wend
%>
    <tr>
        <td width="250" valign="top" align="left" colspan="3"><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=100%></td>
    </tr>
<% if (pollShowTotalVotes=true OR request("AdminMode")=pollAdminModePassword) then %>
    <% if (pollLinesEnabled=true) then%>
        <tr>
            <td width="250" valign="top" align="center" colspan="3"><img src="<%=PollFilePath%>images/<%=pollLinesImage%>" height=1 width=95%></td>
        </tr>
    <% end if%>
    <tr>
        <td width="250" valign="top" align="center" colspan="3"><%=pollFont%><%=pollTxtTotalVotes%> : <%=TotalVotes%></font></td>
    </tr>
<% end if %>
    </form>
    </table>
    </td>
</tr>
</table>
<%
end if
pollRS.close
pollDB.close
end function

'############################################
'# DBProcessError(pollDebugmsg)
'# pollDebugmsg = What msg to display
'############################################
function DBProcessError(pollDebugmsg)
    if pollDebug=true then
        Response.write(pollDebugmsg)
    end if
end function

'############################################
'# FinPollOpenDB()
'# Open database, show error if any problems
'############################################
sub FinPollOpenDB()
On ERROR Resume next
pollDB.open pollConstr ', "Admin",""

if Err.number<>0 then
    Response.write("FinPoll Error : Could not open DataBase, make sure PollFilePath are set correctly.")
    Response.end
end if
ON ERROR GOTO 0
end sub


'############################################
'# Calculate(Result, total)
'# returns a string containg several img tags for displaying .gif images,
'# which represent the graph bar
'############################################
Function Calculate(Result, total)
    Const Max = 12  '// maximum length of the result bar as no. of gif images //
    DIM sGif
    sGif = "<img src="""&PollFilePath&"images/"&pollGraphImage&""" height=""9"" width=""6"">"
    Dim NX, i, sRes
    sRes = ""
    if total = 0 then total=result
    if total <>0 then
    NX = Int(Result / total * Max + 0.5)
    For i = 1 To NX
        sRes = sRes + sGif
    Next
    end if
    Calculate = sRes
End Function
%>
Avatar billede eagleeye Praktikant
11. maj 2006 - 08:11 #1
Kan du uddybe hvilken fejl i du får?

Så vidt jeg kan se får koden lukket for både connection og recordset. Jeg ved ikke om det giver så meget med du kan da prøve dette, hvor .Close er flyttet ud af funktionerne og ladt i "hoved" gennemkørelsen, så connection kun åbnes og lukkes en gang.:



<%
'###################################################
'# Setup
'###################################################
' // Virtuel Path. (Where the files are located)
'PollFilePath="poll/"

PollFilePath="udvidelser/newsandpoll/poll/"
'PollFilePath="http://www.asgi.dk/udvidelser/newsandpoll/poll/"





' // Admin Password
pollAdminModePassword = "Admin"

'Do NOT change the next line
if request("AdminMode")=pollAdminModePassword then PollFilePath=""

'pollDBLocation. Where the database is located
pollDBLocation=server.mappath(PollFilePath&"../../../db/poll.mdb")

' // PollDebug Mode.
' // if true  = Show Error Msg if any Errors. And don't set the cookie date to now + 356days
' // Notice that there is very limited errorhandling.
pollDebug=false

' ####################
' ## Look and feel  ##
' ####################
' // pollBgImage : Used for background color.
pollBgImage = "474971.gif"

' // pollGraphImage : Used for graph bars.
pollGraphImage = "215D84.gif"

' // pollLinesImage : Used for thin lines.
pollLinesImage = "215D84.gif"

' // pollLinesEnabled : Show thin lines or not. Set to true/false.
pollLinesEnabled = true

' // pollFont : Used for text
pollFont = "<font face=""Verdana"" color=""#000000"" size=""1"">"

' // pollHeading : Heading for the poll.
' // Use a image to make it look nice, otherwise uncomment the other line and change the text and/or font
'pollHeading = "<img src="""&PollFilePath&"images/poll_text.gif"">"
pollHeading = "<u><b><font color=""#FFFFFF"" face=""Verdana"" size=""2"">ASGI afstemning</font></b></u>"

'Should the "Total votes" text be shown to users. Set to true or false
pollShowTotalVotes = true

'#####################################################################
'## Text used in script. Change this to your own words/Language    ##
'#####################################################################
pollTxtTotalVotes="Stemmer ialt"

'###################################################
'# Start
'###################################################
dim pollDB,pollRS,pollConstr
dim QID,sQuestion,ShowResultflag

set pollDB=server.createobject("ADODB.Connection")
set pollRS=server.createobject("ADODB.Recordset")
pollConstr = "Provider=MICROSOFT.JET.OLEDB.4.0; Data Source="&pollDBLocation

' // Get active QID and Question from database Question //
FinPollOpenDB()
if request("QID")<>"" then
    QID=request("QID")
    pollRS.open "select * from Questions where QID="&cstr(QID),pollDB,1,2
else
    pollRS.open "select * from Questions where Active=1",pollDB,1,2
end if
if not (pollRS.bof and pollRS.eof) then
    if QID="" then
        QID=pollRS("QID")
    end if
    sQuestion=pollRS("Question")
else
    call DBProcessError("Error : Could not find active poll")
end if
pollRS.close

'Get the cookie
cookieContent = request.cookies("FinPol" & cstr(QID)&sQuestion)

' // See what we should do
if (cookieContent<>"" OR request("AdminMode")=pollAdminModePassword) then
    'Cookie is set = vote has already been cast OR Admin mode
    'So show the result
    call ShowResult()
elseif (cookieContent="" and request.form("finPollOption")<>"") then
    'Vote has been cast and cookie is empty
    call CastVote()
else
    'Show the poll
    call ShowPoll()
end if

' // Cleanup
if pollRS.State > 0 then pollRS.Close
set pollRS=nothing
pollDB.close
set pollDB=nothing

' // The End

'############################################
'# CastVote()
'# Update database with vote and set cookie
'############################################
function CastVote()
    answer=request.form("finPollOption")
'    FinPollOpenDB()  'Udkommenteret for test
    pollRS.open "select * from Poll where QID="&cstr(QID),pollDB,3,3,1
    if not (pollRS.bof and pollRS.eof) then  '// The poll ID is OK //
        'Update database
        pollRS.find ("AnID = "+cstr(answer))
        pollRS("Answer")=pollRS("Answer")+1
        pollRS.update
        '// set a cookie for this poll //
        '// first clear the response object
        response.clear
        response.cookies("FinPol" & cstr(QID)&sQuestion)=Answer
        if pollDebug<>true then
            response.cookies("FinPol" & cstr(QID)&sQuestion).expires=Date + 365
        end if
    else
        call DBProcessError("A poll with ID No."+cstr(QID)+" could not been found.")
    end if
    pollRS.close
    pollDB.close
    'Cleanup since we are doing a redirect
    set pollRS=nothing
    set pollDB=nothing
    '// Redirect the user using ?prd=1 so Netscape don't throw up a object moved error//
    Response.redirect(Request.ServerVariables("SCRIPT_NAME")&"?prd=1&"&request("QueryStringBackup"))
end function

'############################################
'# ShowPoll()
'# Show the poll
'############################################
function ShowPoll()
'    FinPollOpenDB()  'Udkommenteret for test
    pollRS.open "select * from Poll where QID="+cstr(QID)+" order by AnID",pollDB,1,1
    if not (pollRS.bof and pollRS.eof) then
    %>
    <table border="0" cellspacing="0" width="250">
    <tr>
        <td width="100%" background="<%=PollFilePath%>images/<%=pollBgImage%>"><form method="POST" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
        <input type="hidden" value="<%=cstr(QID)%>" name="fQID">
        <input type="hidden" value="<%=Request.QueryString%>" name="QueryStringBackup">
        <table border="0" cellspacing="0" width="250" background="<%=PollFilePath%>images/ffffff.gif">
        <tr>
            <td colspan="3" background="<%=PollFilePath%>images/<%=pollBgImage%>" width="250" align="center"><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=3><br><%=pollHeading%><br><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=3></td>
        </tr>
        <tr>
            <td width="4" valign="top" align="left">&nbsp;</td>
            <td valign="top" align="left" colspan="2" width="246"><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=3><b><%=pollFont%><br><%=sQuestion%><br></font></b><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=3></td>
        </tr>
<% if (pollLinesEnabled=true) then%>
        <tr>
            <td width="250" valign="top" align="center" colspan="3"><img src="<%=PollFilePath%>images/<%=pollLinesImage%>" height=1 width=95%></td>
        </tr>
<% end if%>
    <%
        while not pollRS.eof
            i=i+1
    %>
        <tr>
            <td width="4" valign="top" align="left">&nbsp;</td>
            <td width="12" valign="top" align="left"><input type="radio" value="<%=cstr(i)%>" name="finPollOption"></td>
            <td valign="top" align="left" width="124"><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=3><%=pollFont%><br>
                  <%=pollRS("AnswerText")%></font></td>
        </tr>
    <%
            pollRS.movenext
        wend
    %>
        <tr>
            <td width="250" valign="top" align="left" colspan="3"><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=1></td>
        </tr>
<% if (pollLinesEnabled=true) then%>
        <tr>
            <td width="250" valign="top" align="center" colspan="3"><img src="<%=PollFilePath%>images/<%=pollLinesImage%>" height=1 width=95%></td>
        </tr>
<% end if%>
        <tr>
            <td width="4" valign="top" align="left">&nbsp;</td>
            <td width="12" valign="top" align="left">&nbsp;</td>
            <td valign="top" align="right"><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=1><br><input type="submit" value="Stem" name="Submit" style="font-family: Verdana; font-size: 8pt; font-weight: bold"><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=10><br>
            <img src="<%=PollFilePath%>images/spacer.gif" height=5 width=1></td>
        </tr>
        </form>
        </table>
        </td>
    </tr>
    </table>
    <%
    end if
    pollRS.close
'    pollDB.close  'Udkommenteret for test pollDB.Close er unden for funktion nu
end function

'############################################
'# ShowResult()
'# Show the poll
'############################################
function ShowResult()
'FinPollOpenDB()  'Udkommenteret for test
pollRS.open "select * from Poll where QID="+cstr(QID),pollDB,1,1,1
if not (pollRS.bof and pollRS.eof) then
    set rsTotal=server.createobject("ADODB.Recordset")
    rsTotal.open "Select sum (Answer) from Poll where QID="+cstr(QID), pollDB, 1,1,1
    total=rsTotal(0)
    rsTotal.close
    set rsTotal=nothing
    i=0
    pollRS.movefirst
%>
<table border="0" cellspacing="0" width="250">
<tr>
    <td width="100%" background="<%=PollFilePath%>images/<%=pollBgImage%>"><form method="POST" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
    <input type="hidden" value="<%=cstr(QID)%>" name="fQID">
    <table border="0" cellspacing="0" width="250" background="<%=PollFilePath%>images/ffffff.gif">
    <tr>
        <td colspan="3" background="<%=PollFilePath%>images/<%=pollBgImage%>" width="250" align="center"><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=3><br><%=pollHeading%><br><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=3></td>
    </tr>
    <tr>
        <td width="4" valign="top" align="left">&nbsp;</td>
        <td valign="top" align="left" colspan="2" width="246"><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=3><b><%=pollFont%><br><%=sQuestion%><br></font></b><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=3></td>
    </tr>
<% if (pollLinesEnabled=true) then%>
        <tr>
            <td width="250" valign="top" align="center" colspan="3"><img src="<%=PollFilePath%>images/<%=pollLinesImage%>" height=1 width=95%></td>
        </tr>
<% end if%>
<%
while not pollRS.eof
  i=i+1
%>
    <tr>
        <td width="4" valign="top" align="left"><img src="<%=PollFilePath%>images/spacer.gif" height=5 width=4></td>
        <td width="6" valign="top" align="left"><%=pollFont%>·</font></td>
        <td width="240" valign="top" align="left"><%=pollFont%>
        <b><%=pollRS("AnswerText")%></b><br><%=calculate(pollRS("Answer"),Total)%>&nbsp;<%if ToTal<>0 then Response.write(formatpercent(pollRS("Answer")/Total,0))%>
        <%
        if request("AdminMode")=pollAdminModePassword then
            response.write("<br>"&cstr(pollRS("Answer"))& " Votes")
        end if
        TotalVotes=TotalVotes+cInt(pollRS("Answer"))
        %>
        </font>
        </td>
    </tr>
<%
  pollRS.movenext
wend
%>
    <tr>
        <td width="250" valign="top" align="left" colspan="3"><img src="<%=PollFilePath%>images/spacer.gif" height=3 width=100%></td>
    </tr>
<% if (pollShowTotalVotes=true OR request("AdminMode")=pollAdminModePassword) then %>
    <% if (pollLinesEnabled=true) then%>
        <tr>
            <td width="250" valign="top" align="center" colspan="3"><img src="<%=PollFilePath%>images/<%=pollLinesImage%>" height=1 width=95%></td>
        </tr>
    <% end if%>
    <tr>
        <td width="250" valign="top" align="center" colspan="3"><%=pollFont%><%=pollTxtTotalVotes%> : <%=TotalVotes%></font></td>
    </tr>
<% end if %>
    </form>
    </table>
    </td>
</tr>
</table>
<%
end if
pollRS.close
'pollDB.close  'Udkommenteret for test pollDB.Close er uden for funktion nu
end function

'############################################
'# DBProcessError(pollDebugmsg)
'# pollDebugmsg = What msg to display
'############################################
function DBProcessError(pollDebugmsg)
    if pollDebug=true then
        Response.write(pollDebugmsg)
    end if
end function

'############################################
'# FinPollOpenDB()
'# Open database, show error if any problems
'############################################
sub FinPollOpenDB()
On ERROR Resume next
pollDB.open pollConstr ', "Admin",""

if Err.number<>0 then
    Response.write("FinPoll Error : Could not open DataBase, make sure PollFilePath are set correctly.")
    Response.end
end if
ON ERROR GOTO 0
end sub


'############################################
'# Calculate(Result, total)
'# returns a string containg several img tags for displaying .gif images,
'# which represent the graph bar
'############################################
Function Calculate(Result, total)
    Const Max = 12  '// maximum length of the result bar as no. of gif images //
    DIM sGif
    sGif = "<img src="""&PollFilePath&"images/"&pollGraphImage&""" height=""9"" width=""6"">"
    Dim NX, i, sRes
    sRes = ""
    if total = 0 then total=result
    if total <>0 then
    NX = Int(Result / total * Max + 0.5)
    For i = 1 To NX
        sRes = sRes + sGif
    Next
    end if
    Calculate = sRes
End Function
%>
Avatar billede peterpeter Seniormester
11. maj 2006 - 12:51 #2
TAK
Jeg prøver at indsætte den nye kode i filen og ser hvad der sker !!

Tak - Jeg vender tilbage.

/Peter
Avatar billede peterpeter Seniormester
26. juni 2006 - 23:31 #3
Hej
Jeg har rettet det nu (www.asgi.dk) - Nu må vi se om det virker !!!

Jeg vender tilbage.... STORT TAK !
Avatar billede peterpeter Seniormester
26. juni 2006 - 23:35 #4
..og nu når jeg har dig - du store mester på Eksperten....  ;-)

Jeg har noget kode hvor jeg viser de enkelte medlemmers næste fødselsdag....

Men koden er lavet udfra udtræk fra
Access omkring fødselsdage og er meget tung !! Denne skal nok gøres hurtigere
ved at lade ASP gøre udregningerne istedet for Access, dette vil nok gøre siden hurtigere.....

Men hvordan ???

Har du tid og mulighed ?? Skal jeg indsætte hele filen ???

velkommen4.asp, jeg har ikke sat mig ind i koden ordenligt til at kunne
forklare hvorfor fejlen opstår her, det håber jeg at du/i kan se.

Det er vist her omkring:

starter på linje 358
----------------------------------------------------------------------
Response.Write "<table>"
do while not rs.EOF
  Response.Write "<tr>"
  Response.Write "<td>" & rs("fornavn") & " " & rs("efternavn") & ",</td>"
  Response.Write "<td>den " & rs("vispbirthdatedd") & " " &
MonthName(rs("vispbirthdatemm")) & "</td>"
  Response.Write "</tr>"
  rs.MoveNext
loop
Response.Write "</table>"
rs.Close
Set rs = Nothing
Conn.Close
Set Conn = Nothing


Af hjertet tak og fortsat god dag.....

/Peter
Avatar billede peterpeter Seniormester
16. oktober 2010 - 00:16 #5
Skal lukkes..

Ligger du et svar ??
Avatar billede eagleeye Praktikant
16. oktober 2010 - 09:40 #6
ok det gør jeg.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester