Ver Mensaje Individual
  #8 (permalink)  
Antiguo 03/04/2009, 11:44
Avatar de juanmi321
juanmi321
 
Fecha de Ingreso: septiembre-2004
Mensajes: 262
Antigüedad: 20 años, 8 meses
Puntos: 1
Respuesta: Problema al insertar en una tabla

Hola, vere si puedo explicarme:

TU al principio declaras la variable num_serie3_1 y hasta ese momento viene vacia.

Lo que por logica cuando llega a este if

Código asp:
Ver original
  1. if num_serie3_1 = "" then

Si va entrar

Adentro de ese if, esta primero

Código asp:
Ver original
  1. num_serie3_1 = request.Form("text1")

Lo que hace que vuelvas a meter un valor vacio en num_serie3_1

Despues al igual dentro del if viene tu insert

Código asp:
Ver original
  1. SQL3_1 = "INSERT INTO CELULAR (NUM_SERIE, EQUIPO, MODELO, MAC, PIN, ACCESORIOS, FECHA_ENTREGA_CELULAR, FECHA_RETIRO_CELULAR, ASIGNADO, NO_ASIGNADO, NOTAS) VALUES " &  "('" & num_serie3_1 & "', '" & equipo3_1 & "', '" & modelo3_1 & "', '" & mac3_1 & "', '" & pin3_1 & "', '" & accesorios3_1 & "', '" & fecha_entrega_celular3_1 & "', '" & fecha_retiro_celular3_1 & "', '" & asignado3_1 & "', '" & no_asignado & "', '" & notas3_1 & "')"

Lo cual por logica mete los valores a vacio.

Eso es por q los mete, una solucion seria hacer esto haber si te sirve:
Código asp:
Ver original
  1. <%@LANGUAGE="VBSCRIPT"%>
  2. <script language="vbscript" runat="server">
  3.  
  4.  dim obj_conn3_1, sql3_1, num_serie3_1, equipo3_1, modelo3_1, mac3_1, pin3_1, accesorios3_1, fecha_entrega_celular3_1, fecha_retiro_celular3_1, asignado3_1, no_asignado3_1, notas3_1
  5.  
  6. </script>
  7. <head>
  8. <style type="text/css">
  9.     H1 {border-width: 1; border: solid; text-align:center}
  10. </style>    
  11. <title>EMPRESA S.A.</title>
  12. <style type="text/css">
  13. <!--
  14. body,td,th {
  15.     font-size: 12px;
  16.     color: #000000;
  17. }
  18. body {
  19.     background-color: #FFFFFF;
  20.     background-image: url();
  21.     background-repeat: no-repeat;
  22.     background-position:center;
  23. }
  24. .Estilo2 {font-size: 14px}
  25. .Estilo3 {
  26.     font-size: 18px
  27. }
  28. .Estilo5 {font-size: 18px; font-weight: bold; }
  29. .Estilo4 {
  30.     font-size: 14;
  31.     font-weight: bold;
  32. }
  33. -->
  34. </style>
  35. </head>
  36. <body>
  37.  
  38. <div align="center">
  39.   <p><img src="forosdelweb.com/images/empresa.JPG" width="262" height="76"> </p>
  40.   <p class="Estilo3">Informaci&oacute;n  Tr&aacute;fico De Celulares</p>
  41.   <p class="Estilo3">Empresa S.A.</p>
  42.   <p class="Estilo4">Ingreso de un Nuevo Celular</p>
  43. </div>
  44. <p>&nbsp;</p>
  45. <p>&nbsp;</p>
  46. <%
  47. Dim valor
  48. valor = Request.QueryString("valor")
  49. if num_serie3_1 = "" then
  50. %>
  51.  
  52. <form method="Post" action="agregacelular.asp?valor=1">
  53.  
  54. <table width="308" border="2" align="center" cellpadding="1" cellspacing="0" name="tabla">
  55.   <tr><td colspan=2 align="center" class="Estilo5">Agregar Nuevo CELULAR</td>
  56.   </tr>
  57.   <tr><td colspan="2" height=5></td></tr>
  58.      
  59.    <tr>
  60.       <td width="38%" nowrap class="Estilo4">N&uacute;mero de Serie:</td>
  61.       <td colspan="2">
  62.             <input name ="text1"  size="25" maxlength="15"><BR>
  63.       </td>
  64.    </tr>
  65.    
  66.    <tr>
  67.       <td width="38%" nowrap class="Estilo4">Equipo:</td>
  68.       <td colspan="2">
  69.             <input name="text2" size="25" maxlength="20"><BR>
  70.       </td>
  71.    </tr>
  72.    
  73.    <tr>
  74.       <td width="38%" nowrap class="Estilo4">Modelo:</td>
  75.       <td colspan="2">
  76.             <input name="text3" size="25" maxlength="10"><BR>
  77.       </td>            
  78.    </tr>
  79.    
  80.    <tr>
  81.       <td width="38%" nowrap class="Estilo4">Mac:</td>
  82.       <td colspan="2">
  83.             <input name="tetx4" size="25" maxlength="17"><BR>
  84.       </td>
  85.    </tr>
  86.    
  87.    <tr>
  88.       <td width="38%" nowrap class="Estilo4">Pin:</td>
  89.       <td colspan="2">
  90.             <input name="text5" size="25" maxlength="8"><BR>
  91.       </td>
  92.    </tr>
  93.            
  94.    <tr>
  95.       <td width="38%"  nowrap class="Estilo4">Accesorios</td>
  96.       <td colspan="2">
  97.             <input name="text6" size="25" maxlength="200"><BR>
  98.       </td>
  99.    </tr>
  100.                      
  101.    <tr>
  102.       <td width="38%" nowrap class="Estilo4">Fecha Entrega Celular</td>
  103.       <td colspan="2">
  104.             <input name="text7" size="25" maxlength="10"><BR>
  105.       </td>
  106.    </tr>
  107.            
  108.    <tr>
  109.       <td width="38%" nowrap class="Estilo4">Fecha Retiro Celular</td>
  110.       <td colspan="2">
  111.             <input name="text8" size="25" maxlength="10"><BR>
  112.       </td>
  113.    </tr>
  114.            
  115.    <tr>
  116.       <td width="38%" nowrap class="Estilo4">Asignado</td>
  117.       <td colspan="2">
  118.             <input name="text9" size="25" maxlength="50"><BR>
  119.       </td>
  120.    </tr>
  121.    
  122.    <tr>
  123.       <td width="38%" nowrap class="Estilo4">No Asignado</td>
  124.       <td colspan="2">
  125.             <input name="text10" size="25" maxlength="50"><BR>
  126.       </td>
  127.    </tr>
  128.                                            
  129.    <tr>
  130.       <td width="38%" nowrap class="Estilo4">Notas</td>
  131.       <td colspan="2">
  132.             <input name="text11" size="25" maxlength="200"><BR>
  133.       </td>
  134.    </tr>
  135.                
  136.   <tr>
  137.       <td colspan="6" align="center">
  138.           <input type="Submit" value="&nbsp;&nbsp;Agregar&nbsp;&nbsp;" onClick="return window.confirm('Desea Ingresar el registro')">
  139.       </td>
  140.       <td width="13%"></td>
  141.   </tr>    
  142. </table>
  143. <%end if%>
  144. <%
  145.  if valor = 1 then
  146.  
  147.   num_serie3_1 = request.Form("text1")
  148.   equipo3_1 = request.Form("text2")
  149.   modelo3_1 = request.Form("text3")
  150.   mac3_1 = request.Form("text4")
  151.   pin3_1 = request.Form("text5")
  152.   accesorios3_1 = request.Form("text6")
  153.   fecha_entrega_celular3_1 = request.Form("text7")
  154.   fecha_retiro_celular3_1 = request.Form("text8")
  155.   asignado3_1 = request.Form("text9")
  156.   no_asignado3_1 = request.Form("text10")
  157.   notas3_1 = request.Form("text11")
  158.  
  159.   SQL3_1 = "INSERT INTO CELULAR (NUM_SERIE, EQUIPO, MODELO, MAC, PIN, ACCESORIOS, FECHA_ENTREGA_CELULAR, FECHA_RETIRO_CELULAR, ASIGNADO, NO_ASIGNADO, NOTAS) VALUES " &  "('" & num_serie3_1 & "', '" & equipo3_1 & "', '" & modelo3_1 & "', '" & mac3_1 & "', '" & pin3_1 & "', '" & accesorios3_1 & "', '" & fecha_entrega_celular3_1 & "', '" & fecha_retiro_celular3_1 & "', '" & asignado3_1 & "', '" & no_asignado & "', '" & notas3_1 & "')"
  160.  
  161.   set obj_conn3_1=server.createobject("ADODB.connection")
  162.       obj_conn3_1.open "PRUEBA"
  163.       obj_conn3_1.execute sql3_1
  164.       obj_conn3_1.Close
  165.       set obj_conn3_1 = Nothing
  166.  end if
  167. %>
  168. </form>
  169.  
  170.  
  171. <p align="center">&nbsp;</p>
  172. <td width="50%" height="1" align="left"><form method="POST" name="Volver" action="principal.asp">
  173.     <p align="center">
  174.       <input type="submit" value="  P&aacute;gina Principal " name="   volver   ">
  175.     </p>
  176.   </form></td>
  177.   <td width="50%" height="1" align="left"><form method="POST" name="paginachip" action="celular.asp">
  178.      <p align="center">
  179.       <input type="submit" value=" &nbsp;&nbsp;P&aacute;gina Celular&nbsp;&nbsp; " name="   paginachip   ">
  180.     </p>
  181.  </form></td>
  182.  
  183. <p align="center">&nbsp;</p>
  184. <p align="center" class="Estilo2">Volver a p&aacute;gina Inicio EMPRESA</p>
  185. <p align="center"><a href="paginaempresa.cl/default.aspx" target="_self" class="Estilo2">paginaempresa.cl</a></p>
  186. <p align="center">&nbsp;</p>
  187.  
  188. </body>
  189. </html>


Ya solo seria cosa de adecuarlo y ponerlo bonito, pero analiza lo que hice de esa forma solo insertaria cuando ya trae valores
__________________
<>< EN MOMENTOS DE CRISIS, SOLO LA IMAGINACIÓN ES MÁS IMPORTANTE QUE EL CONOCIMIENTO <><