Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/05/2010, 13:54
th3r0rn
 
Fecha de Ingreso: noviembre-2007
Mensajes: 504
Antigüedad: 16 años, 6 meses
Puntos: 2
Problema con strings en consulta a sqlserver

Hola, tengo un problema con un reportador que hice, puedo conseguir reportes por linea y fecha, el problema es que en el formulario option selecct tengo para seleccionar una linea individual y la opcion all que te listara el reporte de todas las lineas de operaciones, el problema es que solo me deja consultar por todas las lineas y no individual, no se si es por que el valor all tiene como valor un dato numerico el cual es 0 y los demas son cadenas de texto, me da este error:
Microsoft VBScript runtime error '800a000d'

Type mismatch: '[string: "L15N"]'

/MES/luis/show.asp, line 54


eso que dice L15N significa Linea 15 Norte, solo que ese es el valor que necesito consltar, y me da ese error, muestro mi codigo de formulario y el que muestra los daots:
Código ASP:
Ver original
  1. <html>
  2. <head>
  3. <title>meteora uses</title>
  4. <script type="text/javascript" src="meteora/src/meteora.js"></script>
  5.  
  6. <script type="text/javascript">
  7. Meteora.uses('Meteora.Calendar');
  8. Meteora.onStart(
  9.   function () {
  10.     new Calendar(
  11.       'calendar1',
  12.    
  13.       {
  14.         format: '%Y-%m-%d %H:%i',
  15.         minYear: 2005,
  16.         maxYear: 2010,
  17.         showHour: true,
  18.         showMinute: true,
  19.         showMeridiem: true,
  20.         showSecond: true
  21.     });
  22.   }
  23. );
  24. Meteora.uses('Meteora.Calendar');
  25. Meteora.onStart(
  26.   function () {
  27.     new Calendar(
  28.       'calendar2',
  29.    
  30.       {
  31.         format: '%Y-%m-%d %H:%i',
  32.         minYear: 2005,
  33.         maxYear: 2010,
  34.         showHour: true,
  35.         showMinute: true,
  36.         showMeridiem: true,
  37.         showSecond: true
  38.     });
  39.   }
  40. );
  41. </script>
  42.  
  43. </head>
  44. <body>
  45. <form action="show.asp" method="post">
  46. Fecha inicio: <input  type="text" name="calendar1" id="calendar1"/><br><br>
  47. Fecha fin:    <input  type="text" name="calendar2" id="calendar2"/><br>
  48. <%
  49. Dim conexion,registros
  50. SET conexion=Server.CreateObject("ADODB.Connection")
  51. conexion.Open"PROVIDER=SQLOLEDB; DATA SOURCE=VALP-MESSRV01;UID=sa;PWD=messrv;DATABASE=WASP "
  52. SET registros=Server.CreateObject("ADODB.RecordSet")
  53. registros.open"SELECT linea FROM optimas",conexion
  54. response.write("<select name='linea'>")
  55. response.write("<option value=1>all</option>")
  56. do while not registros.eof
  57. response.write("<option value="&registros.fields("linea")&">"&registros.fields("linea")&"</option>")
  58.  
  59. registros.movenext
  60. loop
  61. response.write("</select>")
  62. conexion.close
  63. %>
  64.  
  65. <input type="submit" value="consultar">
  66. </form>
  67. </body>
  68. </html>
y el reportador: que muestra:
Código ASP:
Ver original
  1. <% Response.Buffer = False
  2. Server.ScriptTimeout = 1400
  3. %>
  4.  
  5. <html>
  6. <head>
  7. <title>Reporte WAS2</title>
  8. </head>
  9. <body>
  10. <style type="text/css">
  11. table.sample {
  12.     border-width: 1px;
  13.     border-spacing: 2px;
  14.     border-style: groove;
  15.     border-color: green;
  16.     border-collapse: collapse;
  17.     background-color: rgb(255, 255, 240);
  18. }
  19. table.sample th {
  20.     border-width: 1px;
  21.     padding: 3px;
  22.     border-style: inset;
  23.     border-color: red;
  24.     background-color: ;
  25.     -moz-border-radius: 0px 0px 0px 0px;
  26. }
  27. table.sample td {
  28.     border-width: 1px;
  29.     padding: 3px;
  30.     border-style: inset;
  31.     border-color: red;
  32.     background-color: ;
  33.     -moz-border-radius: 0px 0px 0px 0px;
  34. }
  35. </style>
  36. <p align="center"><table border="1" CLASS="sample"></p>
  37. <tr>
  38. <td><b>Linea</b></td>
  39. <td><b>Peso</b></td>
  40. <td><b>Tubo</b></td>
  41. <td><b>Fecha</b></td>
  42. </tr>
  43. <%
  44.  
  45. dim conexion,calendar1,calendar2,registros,linea
  46. calendar1=request.form("calendar1")
  47. calendar2=request.form("calendar2")
  48. linea=request.form("linea")
  49. response.write(linea)
  50. SET conexion=Server.CreateObject("ADODB.Connection")
  51. conexion.Open "PROVIDER=SQLOLEDB; DATA SOURCE=VALP-MESSRV01;UID=sa;PWD=messrv;DATABASE=wasp "
  52. SET registros=Server.CreateObject("ADODB.RecordSet")
  53. 'registros.open"SELECT peso,tubo from pesos where fecha  between '"&calendar1&"' AND '"&calendar2&"'",conexion
  54. if linea=1 Then
  55.  
  56. registros.open"SELECT p.peso,p.tubo,p.fecha, o.linea FROM pesos as p, optimas as o where o.codigo = p.codOptima  AND p.fecha Between '"&calendar1&"' AND '"&calendar2&"'order by linea",conexion
  57. else
  58. registros.open"SELECT p.peso,p.tubo,p.fecha, o.linea FROM pesos as p, optimas as o where o.codigo = p.codOptima and o.linea = '"&linea&"'  AND p.fecha Between '"&calendar1&"' AND '"&calendar2&"'",conexion    
  59. end if
  60. do while not registros.eof
  61. response.write("<tr>")
  62. response.write("<td>"&registros.fields("linea")&"</td>")
  63. response.write("<td>"&registros.fields("peso")&"</td>")
  64. response.write("<td>"&registros.fields("tubo")&"</td>")
  65. response.write("<td>"&registros.fields("fecha")&"</td>")
  66. registros.movenext
  67.  
  68.  
  69.  
  70.  
  71. loop
  72. conexion.close
  73.  
  74.  
  75. 'SELECT p.peso,p.tubo,p.fecha, o.linea FROM pesos as p, optimas as o where o.codigo = p.codOptima and o.linea = 'L02N'  AND p.fecha Between '2010-05-11 09:42:34.000' AND '2010-05-11 09:42:39.000'
  76.  
  77. %>
  78. </tr>
  79. </table>
  80. </body>
  81. </html>