Foros del Web » Programando para Internet » ASP Clásico »

¿Porque el error?

Estas en el tema de ¿Porque el error? en el foro de ASP Clásico en Foros del Web. Amigos tengo el siguiente script: Pag1.asp <% dim conn dim rs set conn = Server.CreateObject("ADODB.Connection") set rs = Server.CreateObject("ADODB.Recordset") conn.Open "DSN=cds" rs.ActiveConnection = conn rs.Open ...
  #1 (permalink)  
Antiguo 14/07/2003, 13:37
Avatar de El_Metallick  
Fecha de Ingreso: noviembre-2002
Ubicación: Santiago, Chile
Mensajes: 1.718
Antigüedad: 21 años, 7 meses
Puntos: 16
¿Porque el error?

Amigos tengo el siguiente script:

Pag1.asp

<%

dim conn
dim rs

set conn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset")
conn.Open "DSN=cds"
rs.ActiveConnection = conn
rs.Open "SELECT * FROM cds ORDER BY title ASC"
while not rs.EOF
%>
<font face="Verdana" size="2" color="black">
<h2><%=rs.Fields(1).Value%></h2>
<b>Author:</b> <%=rs.Fields(2).Value%><br>
<b>Summary:</b> <%=rs.Fields(3).Value%><br>
<b>Price:</b> <%=FormatCurrency(rs.Fields(4).Value, 2)%><br>
</font>
<br>
<form name="frmRate<%=rs.Fields(0).value%>" action="rate.asp">
<input type="hidden" name="cdId" value="<%=rs.Fields(0).value%>">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="black">
<font face="Verdana" size="1" color="white">
<%
for i = 1 to 10
Response.Write "&nbsp;" & i & " <input name='rating' type='radio' value='1'> "
next
%>
</font>
<input type="submit" value="Rate It!">
</td>
</tr>
</table>
</form>
<hr size="1" color="#08496B" NOSHADE>
<%
rs.MoveNext
wend
%>


Pag2.asp

<%

dim conn
dim rs
dim cdId
dim visitorIP
dim rating
dim cookie
dim cookieRated

cdId = Request.Form("cdId")
rating = Request.Form("rating")
visitorIP = Request.ServerVariables("REMOTE_ADDR")
cookie = Request.Cookies("rate_" & cdId)
set conn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset")

conn.Open "DSN=cds"
rs.ActiveConnection = conn
if cookie = "" then
cookieRated = false
else
cookieRated = true
end if
if rating = "" then

'Invalid rating
%>

<font face="Verdana" size="2" color="black">
<h2>Invalid Rating</h2>
You must select a rating first!<br><br>
<a href="javascript:history.go(-1)">Go Back</a>
</font>

<%

else

'Valid rating, make sure visitor hasn't already voted
'by checking the ratings table
rs.Open "SELECT COUNT(*) FROM ratings WHERE ip='" & visitorIP & "' AND cdId=" & cdId
if rs.Fields(0).Value = 0 then
if cookieRated = false then
'Visitor hasn't rated yet, let's add it
conn.Execute "INSERT INTO ratings(rating, ip, cdId) VALUES(" & rating & ", '" & visitorIP & "', " & cdId & ")"

Response.Cookies("rate_" & cdId) = true
Response.Cookies("rate_" & cdId).expires = Date() + 30
%>
<font face="Verdana" size="2" color="black">
<h2>Thank You For Rating!</h2>
Your CD rating has been added to our database.<br><br>
<a href="showcds.asp">Continue</a>
</font>
<%
else
'Visitor has already rated this article
%>
<font face="Verdana" size="2" color="black">
<h2>Already Rated</h2>
You have already rated this article!<br><br>
<a href="javascript:history.go(-1)">Go Back</a>
</font>
<%
end if
else
'Visitor has already rated this article
%>
<font face="Verdana" size="2" color="black">
<h2>Already Rated</h2>
You have already rated this article!<br><br>
<a href="javascript:history.go(-1)">Go Back</a>
</font>
<%
end if
%>


Pag3.asp

<%
function ShowRating(cdId)

const MIN_RATINGS_BEFORE_SHOW = 3

dim rs1
dim avgRating
dim avgWhole
dim decPart
dim decCalc
dim finalRating
dim altText
set rs1 = Server.CreateObject("ADODB.Recordset")

rs1.ActiveConnection = conn
rs1.Open "SELECT SUM(rating), COUNT(*) FROM ratings WHERE cdId = " & cdId

if rs1.Fields(1) < MIN_RATINGS_BEFORE_SHOW then
'No ratings for this CD just yet
Response.Write "[CD not rated yet]"
else

'This CD has ratings, let's display the average
avgRating = rs1.Fields(0).Value / rs1.Fields(1).Value
if Instr(1, CStr(avgRating), ".") > 0 then

'The average rating is a decimal, we need to either
'round the value up/down

avgWhole = Left(CStr(avgRating), Instr(1, CStr(avgRating), ".")-1)
decPart = Mid(CStr(avgRating), Instr(1, CStr(avgRating), ".")+1, 2)

if decPart <> "" then
'Work out whether or not we have to round this
'rating up or down

if CInt(decPart) >= 5 then
decCalc = .5
else
decCalc = 0
end if

finalRating = CInt(avgWhole) + CCur(decCalc)

else
finalRating = avgRating
end if
else
finalRating = avgRating
end if
'Setup the alt text for the images
altText = "Average visitor rating of " & finalRating & " out of 10"

for i = 1 to CInt(finalRating)
Response.Write "<img alt='" & altText & "' src='rating_on.gif'>"
next

if CInt(finalRating) <> finalRating then
'This article has a .5 rating, such as 5.5
Response.Write "<img alt='" & altText & "' src='rating_half.gif'>"

for i = CInt(finalRating)+2 to 10
Response.Write "<img alt='" & altText & "' src='rating_off.gif'>"
next
else
for i = CInt(finalRating)+1 to 10
Response.Write "<img alt='" & altText & "' src='rating_off.gif'>"
next
end if
%>


y me dice que no se puede conectar a la base de datos siendo que los dns estan configurados a esa base de datos.
Agradesco cualquier ayuda porfavor.

Gracias desde ya
__________________
Haz la guerra en la cama y el amor donde se te de la gana...
El tiempo es el mejor maestro, lo único malo es que te mata...¡¡Aprovecha tu tiempo!!
  #2 (permalink)  
Antiguo 14/07/2003, 13:56
Avatar de Saruman  
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 21 años
Puntos: 5
donde tas llamando la base de datos??? no lo veo...

prueba con esta coneccion, es mas sencilla:

<%
dim Master
dim sql
dim RS

Set Master = Server.CreateObject("ADODB.Connection")
Master.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("datos.mdb"))

sql = "SELECT * FROM cds ORDER BY title ASC"
set RS = Master.Execute(sql)
%>

ok
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:20.