Ver Mensaje Individual
  #18 (permalink)  
Antiguo 19/04/2007, 12:45
mary*
 
Fecha de Ingreso: septiembre-2006
Mensajes: 161
Antigüedad: 18 años, 7 meses
Puntos: 0
Re: Como Insertar Datos???

Hola a todos!!!

Bueno pues intenté otro código...es más simple pero creo que ya logré algo...ya después lo iré haciendo más complejo...solo que tengo un problema...

Muestra el formulario, lo llenas y envias los datos, lo cual ya hace...y ademas del boton de enviar y reestablecer le puse un boton que me envia a otra pagina para consultar lo que tengo en mi tabla...solamente que cada que oprimo ese boton del link efectivamente me envia a la pagina y me muestra los datos pero también me agrega nuevos datos en blanco...creo qu esto lo puedo evitar condicionando q para que lo envie el dato no debe ser "null"...pero no se como hacer esto...o alguna otra sugerencia??...espero me puedan ayudar!!!


Código:
<%
	'ESTOS REQUEST.FORM SON LOS NOMBRES DE LOS CAMPOS DE FORM DE LA PAGINA ANTERIOR
	if (Request.querystring("cia")) and (Request.querystring("vendedor")) and (Request.querystring("descrip")) and isdate(Request.Form("fecha_v")) and (Request.querystring("contacto")) and (Request.querystring("tel")) and (Request.querystring("comentario")) then 
	Response.Redirect "Captura.asp"
	end if

	vcia= (Request.Form("cia"))
	vvend= (Request.Form("vendedor"))
	vdesc= (Request.Form("descrip"))
	vfechv= (Request.Form("fecha_v"))
	vcont= (Request.Form("contacto"))
	vtel= (Request.Form("tel"))
	vcom= (Request.Form("comentario"))	
	
	'Conección con la BD
	sConnStr = "Driver={SQL Server};Server=MGUE;Database=Ventas;UID=sa;Password=sa;"
	Set objConn = Server.CreateObject("ADODB.Connection") 
	objConn.Open sConnStr
	
	'Ligamos la tabla temporal a la vista de la BD
	strSQL_N = "INSERT INTO CLIENTES_POR_CONT (CIA, VENDEDOR, DESCRIP, FECHA_VIST, CONTACTO, TEL, COMENTARIO) VALUES ('" & vcia & "', '" & vvend & "' , '" & vdesc & "' , '" & vfechv & "' , '" & vcont & "' , '" & vtel & "' , '" & vcom & "')"
	Set RS = objConn.execute(strSQL_N)
%>	
	
<html>
<head>
<title>Captuta</title>
</head>
<body bgcolor="#CCFFCC">
<p align="center">VENTAS</p>
<p align="center"><font face="Verdana">Clientes por Contactar : </font></p>
<form method="POST" action="Captura1.asp">
<table border="1" width="100%">
<tr>
  <td height="35" colspan="2" bgcolor="#008000"><div align="center"><font color="#FFFFFF">Capturar Datos</font></div></td>
</tr>
<tr>
  <td>COMPA&Ntilde;IA : </td>
  <td><p align="left">
    <input type="text" name="cia" size="100">&nbsp;</td>
</tr>
<tr>
  <td>VENDEDOR : </td>
  <td><p align="left">
    <input type="text" name="vendedor" size="100">&nbsp;</td>
</tr>
<tr>
  <td>DESCRIPCION:</td>
  <td><input type="text" name="descrip" size="100"></td>
</tr>
<tr>
  <td>FECHA VISITA :</td>
  <td><p align="left">
    <input type="text" name="fecha_v" size="100">&nbsp;</td>
</tr>
<tr>
  <td>CONTACTO : </td>
  <td><p align="left">
    <input type="text" name="contacto" size="100">&nbsp;</td>
</tr>
<tr>
  <td>TELEFONO :</td>
  <td><input type="text" name="tel" size="100"></td>
</tr>
<tr>
  <td width="27%">COMENTARIO: </td>
<td width="73%">
<p align="left">
  <input type="text" name="comentario" size="100">
</p></td>
</tr>
</table>
<p>
  <input type="submit" value="Enviar" name="B1"> 
  <input type="reset" value="Restablecer" name="B2">
</p>
</form>
<p align="center"><a href="http://127.0.0.1/Ventas/Consulta_Datos1.asp">Consultar</a></p>
</body>
</html>