Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/12/2009, 08:54
Avatar de neodani
neodani
 
Fecha de Ingreso: marzo-2007
Mensajes: 1.811
Antigüedad: 18 años, 2 meses
Puntos: 20
Respuesta: Error al imprimir datos de una consulta SQL

Cita:
Iniciado por JuanRAPerez Ver Mensaje
toc toc


Esta línea esta como comentario en tu código

'rs.open SQL, conn

quitale el comentario y prueba

suerte
Muchas gracias JuanRAPerez por tu interés.
Quizás con el código entero me podéis aconsejar mejor. Esa linea que me dices la tengo activada más arriba, mira.

Código asp:
Ver original
  1. <%
  2.  
  3. Set conn = Server.CreateObject("ADODB.Connection")
  4. conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=xxxxxxxxxx;UID=xxxxxxx;PWD=xxxx;DATABASE=incidencias"
  5.  
  6. 'This code block will create a recordset
  7. Set rs = Server.CreateObject("ADODB.Recordset")
  8. SQL = "SELECT * FROM NSG_COMENTARIS_INCIDENCIES WHERE (creat_per = '12571') AND (YEAR(data) LIKE '2009') AND (DAY(data) LIKE '9') AND (MONTH(data) LIKE '12')"
  9. rs.open SQL, conn
  10.  
  11. 'will iterate to display the records got from the database
  12. response.write("<table>")
  13. 'response.write("<thead>" & "<th>" & "ID_Comentari" & "</th>" & "<th>" & "ID_Incidencia" & "</th>" & "<th>" & "Data" & "</th>" & "<th>" & "Descripcio" & "</th>" & "<th>" & "Temps Dedicat" & "</th>" & "<th>" & "Creat Per" & "</th>" & "</thead>")
  14. response.write("<thead>" & "<th>" & "ID_Comentari" & "</th>" & "<th>" & "ID_Incidencia" & "</th>" & "<th>" & "Data" & "</th>" & "<th>" & "Temps Dedicat" & "</th>" & "<th>" & "Creat Per" & "</th>" & "</thead>")
  15.  
  16. While Not rs.EOF
  17.   response.write("<tr>")
  18.   'response.write("<td>" & rs("id_comentari") & "</td>" & "<td>" & rs("id_incidencia") & "</td>" & "<td>" & rs("data") & "</td>" & "<td>" & rs("descripcio") & "</td>" & "<td>" & rs("temps_dedicat") & "</td>" & "<td>" & rs("creat_per") & "</td>")
  19.   response.write("<td>" & rs("id_comentari") & "</td>" & "<td>" & rs("id_incidencia") & "</td>" & "<td>" & rs("data") & "</td>" & "<td>" & rs("temps_dedicat") & "</td>" & "<td>" & rs("creat_per") & "</td>")
  20.  
  21.   response.write("</tr>")
  22.   rs.MoveNext
  23. Wend
  24. response.write("</table>")
  25. 'closes the connection
  26. rs.close
  27. conn.close
  28. Set rs = Nothing
  29. Set conn = Nothing
  30.  
  31.  
  32. 'imprimo usuarios con sus tiempos
  33. Set conn = Server.CreateObject("ADODB.Connection")
  34. conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=xxxxxxxxxx;UID=xxxxxxx;PWD=xxxx;DATABASE=incidencias"
  35.  
  36. Set rs = Server.CreateObject("ADODB.Recordset")
  37. rs.open SQL, conn
  38. SQL = "SELECT SUM(temps_dedicat) AS tiempos FROM NSG_COMENTARIS_INCIDENCIES WHERE (creat_per = '12571') AND (YEAR(data) LIKE '2009') AND (DAY(data) LIKE '9') AND (MONTH(data) LIKE '12')"
  39. 'rs.open SQL, conn
  40.  
  41. 'will iterate to display the records got from the database
  42. response.write("<table>")
  43. response.write("<thead>" & "<th>" & "Trabajador" & "</th>" & "<th>" & "Tiempo en Min." & "</th>" & "</thead>")
  44. While Not rs.EOF
  45.   response.write("<tr>")
  46.   response.write("<td>" & "Dani" & "</td>" & "<td>" & rs("tiempos") & "</td>")
  47.   response.write("</tr>")
  48.   rs.MoveNext
  49. Wend
  50. response.write("</table>")
  51.  
  52.  
  53. 'closes the connection
  54. rs.close
  55. conn.close
  56. Set rs = Nothing
  57. Set conn = Nothing
  58.  
  59. %>

Muchas gracias de antemano!