Que tal amigos profesionales del ASP
soy un novato que necesita ayuda para poder entregar su proyecto de escuela, pero no puedo insertar es regsitro y no se a que se deva, estoy tratando de insertar datos e una tabla que esta relacionada, pero ya quite la relacion y ni asi,voy a poner todo mi codigo, OK, espero alguien me pueda ayudar,
<%
'Recogemos los valores del formulario
id_compra = Request.Form("id_compra")
fecha_compra = Request.Form("fecha_compra")
cantidad_material = Request.Form("cantidad_material")
id_proveedor = Request.Form("id_proveedor")
nombre_material = Request.Form("nombre_material")
unidad_medida = Request.Form("unidad_medida")
precio_unitario = Request.Form("precio_unitario")
sub_total = Request.Form("sub_total")
costo_total = Request.Form("costo_total") '"& Request.Form("id_proveedor")&"'
basedatos = Server.MapPath("../conect_db/bd_cl.mdb")
Set conexion = Server.CreateObject("ADODB.Connection")
conexion.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & basedatos & ";"
Set RS = Server.CreateObject("ADODB.RecordSet")
'Ahora creamos la sentencia SQL
sSQL="Insert Into compras (id_compra, id_proveedor, fecha_compra, nombre_material, unidad_medida, cantidad_material, precio_unitario, sub_total, costo_total) values ('" & id_compra & "','" & id_proveedor & "','"& fecha_compra&"','"& nombre_material &"','"& unidad_medida &"','"& cantidad_material &"','"& precio_unitario &"','"& sub_total &"','"& costo_total&"')"
'Ejecutamos la orden
set RS = conexion.Execute(sSQL)
%>
<%
'Cerramos el sistema de conexion
conexion.Close
%>
<%Response.Redirect("compras_ini.asp")%>
NOTA: MI BASE DE DATOS SI ESTA RELACIONADA y aun asi quita la relacion y no ingresa mas que datos en blanco
ESTE EL EL FORMULARIO EN DONDE SACO LOS DATOS, ES MUCHO PERDONEN
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<title>Modulo de Compras</title>
<style type="text/css">
div.menuBar,
div.menuBar a.menuButton,
div.menu,
div.menu a.menuItem {
font-family: "MS Sans Serif", Arial, sans-serif;
font-size: 8pt;
font-style: normal;
font-weight: normal;
color: #000000;
}
div.menuBar {
background-color: #d0d0d0;
border: 2px solid;
border-color: #f0f0f0 #909090 #909090 #f0f0f0;
padding: 4px 2px 4px 2px;
text-align: left;
}
div.menuBar a.menuButton {
background-color: transparent;
border: 1px solid #d0d0d0;
color: #000000;
cursor: default;
left: 0px;
margin: 1px;
padding: 2px 6px 2px 6px;
position: relative;
text-decoration: none;
top: 0px;
z-index: 100;
}
div.menuBar a.menuButton:hover {
background-color: transparent;
border-color: #f0f0f0 #909090 #909090 #f0f0f0;
color: #000000;
}
div.menuBar a.menuButtonActive,
div.menuBar a.menuButtonActive:hover {
background-color: #a0a0a0;
border-color: #909090 #f0f0f0 #f0f0f0 #909090;
color: #ffffff;
left: 1px;
top: 1px;
}
div.menu {
background-color: #d0d0d0;
border: 2px solid;
border-color: #f0f0f0 #909090 #909090 #f0f0f0;
left: 0px;
padding: 0px 1px 1px 0px;
position: absolute;
top: 0px;
visibility: hidden;
z-index: 101;
}
div.menu a.menuItem {
color: #000000;
cursor: default;
display: block;
padding: 3px 1em;
text-decoration: none;
white-space: nowrap;
}
div.menu a.menuItem:hover, div.menu a.menuItemHighlight {
background-color: #000080;
color: #ffffff;
}
div.menu a.menuItem span.menuItemText {}
div.menu a.menuItem span.menuItemArrow {
margin-right: -.75em;
}
div.menu div.menuItemSep {
border-top: 1px solid #909090;
border-bottom: 1px solid #f0f0f0;
margin: 4px 2px;
}
.Estilo2 {color: #ECE9D8}
</style>
<script type="text/javascript">
<!--
function Browser() {
var ua, s, i;
this.isIE = false;
this.isNS = false;
this.version = null;
ua = navigator.userAgent;
s = "MSIE";
if ((i = ua.indexOf(s)) >= 0) {
this.isIE = true;
this.version = parseFloat(ua.substr(i + s.length));
return;
}
s = "Netscape6/";
if ((i = ua.indexOf(s)) >= 0) {
this.isNS = true;
this.version = parseFloat(ua.substr(i + s.length));
return;
}
// Treat any other "Gecko" browser as NS 6.1.
s = "Gecko";
if ((i = ua.indexOf(s)) >= 0) {
this.isNS = true;
this.version = 6.1;
return;
}
}
var browser = new Browser();
//----------------------------------------------------------------------------
// Code for handling the menu bar and active button.
//----------------------------------------------------------------------------
var activeButton = null;
// Capture mouse clicks on the page so any active button can be
// deactivated.
if (browser.isIE)
document.onmousedown = pageMousedown;
else
document.addEventListener("mousedown", pageMousedown, true);
function pageMousedown(event) {
var el;
if (activeButton == null)
return;
if (browser.isIE)
el = window.event.srcElement;
else
el = (event.target.tagName ? event.target : event.target.parentNode);
if (el == activeButton)
return;
if (getContainerWith(el, "DIV", "menu") == null) {
resetButton(activeButton);
activeButton = null;
}
}
function buttonClick(event, menuId) {
var button;
if (browser.isIE)
button = window.event.srcElement;
else
button = event.currentTarget;
button.blur();
if (button.menu == null) {
button.menu = document.getElementById(menuId);
menuInit(button.menu);
}
if (activeButton != null)
resetButton(activeButton);
if (button != activeButton) {
depressButton(button);
activeButton = button;
}
else
activeButton = null;
return false;
}
function buttonMouseover(event, menuId) {
var button;
if (browser.isIE)
button = window.event.srcElement;
else
button = event.currentTarget;
if (activeButton != null && activeButton != button)
buttonClick(event, menuId);
}
function depressButton(button) {
var x, y;
button.className += " menuButtonActive";
x = getPageOffsetLeft(button);
y = getPageOffsetTop(button) + button.offsetHeight;
if (browser.isIE) {
x += button.offsetParent.clientLeft;
y += button.offsetParent.clientTop;
}
button.menu.style.left = x + "px";
button.menu.style.top = y + "px";
button.menu.style.visibility = "visible";
}
function resetButton(button) {
removeClassName(button, "menuButtonActive");
if (button.menu != null) {
closeSubMenu(button.menu);
button.menu.style.visibility = "hidden";
}
}
function menuMouseover(event) {
var menu;
if (browser.isIE)
menu = getContainerWith(window.event.srcElement, "DIV", "menu");
else
menu = event.currentTarget;
if (menu.activeItem != null)
closeSubMenu(menu);
}
function menuItemMouseover(event, menuId) {
var item, menu, x, y;
if (browser.isIE)
item = getContainerWith(window.event.srcElement, "A", "menuItem");
else
item = event.currentTarget;
menu = getContainerWith(item, "DIV", "menu");
if (menu.activeItem != null)
closeSubMenu(menu);
menu.activeItem = item;
item.className += " menuItemHighlight";
if (item.subMenu == null) {
item.subMenu = document.getElementById(menuId);
menuInit(item.subMenu);
}
x = getPageOffsetLeft(item) + item.offsetWidth;
y = getPageOffsetTop(item);
var maxX, maxY;
if (browser.isNS) {
maxX = window.scrollX + window.innerWidth;
maxY = window.scrollY + window.innerHeight;
}
if (browser.isIE && browser.version < 6) {
maxX = document.body.scrollLeft + document.body.clientWidth;
maxY = document.body.scrollTop + document.body.clientHeight;
}
if (browser.isIE && browser.version >= 6) {
maxX = document.documentElement.scrollLeft + document.documentElement.clientWidth;
maxY = document.documentElement.scrollTop + document.documentElement.clientHeight;
}
maxX -= item.subMenu.offsetWidth;
maxY -= item.subMenu.offsetHeight;
if (x > maxX)
x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
+ (menu.offsetWidth - item.offsetWidth));
y = Math.max(0, Math.min(y, maxY));
item.subMenu.style.left = x + "px";
item.subMenu.style.top = y + "px";
item.subMenu.style.visibility = "visible";
if (browser.isIE)
window.event.cancelBubble = true;
else
event.stopPropagation();
}
function closeSubMenu(menu) {
if (menu == null || menu.activeItem == null)
return;
if (menu.activeItem.subMenu != null) {
closeSubMenu(menu.activeItem.subMenu);
menu.activeItem.subMenu.style.visibility = "hidden";
menu.activeItem.subMenu = null;
}
removeClassName(menu.activeItem, "menuItemHighlight");
menu.activeItem = null;
}
function menuInit(menu) {
var itemList, spanList
var textEl, arrowEl;
var itemWidth;
var w, dw;
var i, j;
if (browser.isIE) {
menu.style.lineHeight = "2.5ex";
spanList = menu.getElementsByTagName("SPAN");
for (i = 0; i < spanList.length; i++)
if (hasClassName(spanList[i], "menuItemArrow")) {
spanList[i].style.fontFamily = "Webdings";
spanList[i].firstChild.nodeValue = "4";
}
}
itemList = menu.getElementsByTagName("A");
if (itemList.length > 0)
itemWidth = itemList[0].offsetWidth;
else
return;
for (i = 0; i < itemList.length; i++) {
spanList = itemList[i].getElementsByTagName("SPAN")
textEl = null
arrowEl = null;
for (j = 0; j < spanList.length; j++) {
if (hasClassName(spanList[j], "menuItemText"))
textEl = spanList[j];
if (hasClassName(spanList[j], "menuItemArrow"))
arrowEl = spanList[j];
}
if (textEl != null && arrowEl != null)
textEl.style.paddingRight = (itemWidth
- (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
}
if (browser.isIE) {
w = itemList[0].offsetWidth;
itemList[0].style.width = w + "px";
dw = itemList[0].offsetWidth - w;
w -= dw;
itemList[0].style.width = w + "px";
}
}
function getContainerWith(node, tagName, className) {
while (node != null) {
if (node.tagName != null && node.tagName == tagName &&
hasClassName(node, className))
return node;
node = node.parentNode;
}
return node;
}
function hasClassName(el, name) {
var i, list;
list = el.className.split(" ");
for (i = 0; i < list.length; i++)
if (list[i] == name)
return true;
return false;
}
function removeClassName(el, name) {
var i, curList, newList;
if (el.className == null)
return;
newList = new Array();
curList = el.className.split(" ");
for (i = 0; i < curList.length; i++)
if (curList[i] != name)
newList.push(curList[i]);
el.className = newList.join(" ");
}
function getPageOffsetLeft(el) {
var x;
x = el.offsetLeft;
if (el.offsetParent != null)
x += getPageOffsetLeft(el.offsetParent);
return x;
}
function getPageOffsetTop(el) {
var y;
y = el.offsetTop;
if (el.offsetParent != null)
y += getPageOffsetTop(el.offsetParent);
return y;
}
function aMayusculas(campo){
campo.value = campo.value.toUpperCase();
}
function cambiaEstado(texto){
window.status=texto;
}
//busca caracteres que no sean espacio en blanco en una cadena
function vacio(q) {
for ( i = 0; i < q.length; i++ ) {
if ( q.charAt(i) != " " ) {
return true
}
}
return false
}
//valida que el campo no este vacio y no tenga solo espacios en blanco
function validar(F) {
if( vacio(F.campo.value) == false ) {
alert("Introduzca un cadena de texto.")
return false
// } else {
// alert("OK")
//cambiar la linea siguiente por return true para que ejecute la accion del formulario
// return false
}
}
function uno(src,color_entrada) {
src.bgColor=color_entrada;src.style.cursor="hand";
}
function dos(src,color_default) {
src.bgColor=color_default;src.style.cursor="defaul t";
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,men ubar=0,resizable=1,width=530,height=440');");
}
//-->
</script>
</head>
<body bgcolor="#FFCCCC">
<div align="left">
<table border="0" width="100%" align="left" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" style="border-collapse: collapse" id="table1">
<tr>
<td height="22" colspan="5">
<div class="menuBar" style="width:373px;height:25px">
<a class="menuButton" href="" onclick="return buttonClick(event, 'archivoMenu');" onmouseover="buttonMouseover(event, 'archivoMenu');">Archivo</a>
<a class="menuButton" href="" onclick="return buttonClick(event, 'registrosMenu');" onmouseover="buttonMouseover(event, 'registrosMenu');">Registros</a>
<a class="menuButton" href="" onclick="return buttonClick(event, 'edicionMenu');" onmouseover="buttonMouseover(event, 'edicionMenu');">Edicion</a>
<a class="menuButton" href="" onclick="return buttonClick(event, 'ayudaMenu');" onmouseover="buttonMouseover(event, 'ayudaMenu');">Ayuda</a>
</div>
<div id="archivoMenu" class="menu" onmouseover="menuMouseover(event)">
<a class="menuItem" href="../panel_load.asp">Salir de Compras</a>
</div>
<div id="registrosMenu" class="menu" onmouseover="menuMouseover(event)">
<a class="menuItem" href="">Registros Siguientes</a>
<a class="menuItem" href="">Registros Anteriores</a>
</div>
<div id="edicionMenu" class="menu" onmouseover="menuMouseover(event)">
<a class="menuItem" href="nueva_compra.asp">Nuevo</a>
<a class="menuItem" href="editar_compra.asp">Editar</a>
<a class="menuItem" href="eliminar_compra.asp">Eliminar</a>
<a class="menuItem" >Guardar</a>
<a class="menuItem" >Cancelar</a>
<a class="menuItem" href="actualizar_compra.asp">Actualizar</a>
<a class="menuItem" href="javascript
:popUp('busqueda.asp')">Buscar</a>
</div>
<div id="ayudaMenu" class="menu" onmouseover="menuMouseover(event)">
<a class="menuItem" href="chambenado.html">Ayuda de sistema</a>
<a class="menuItem" href="chambenado.html">Acerca de ...</a>
<a class="menuItem" href="chambenado.html">CREDITOS</a>
</div>
</td>
</tr>
<tr>
<td colspan="5"><a href="nueva_compra.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('nuevo','','../imagenes_aplicacion/Botones/Nuevo2.bmp',1)"><img name="nuevo" border="0" src="../imagenes_aplicacion/Botones/Nuevo.bmp" alt="Alta de Cliente"></a><a href="editar_compra.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('editar','','../imagenes_aplicacion/Botones/Editar2.bmp',1)"><img name="editar" border="0" src="../imagenes_aplicacion/Botones/Editar.bmp" alt="Editar Informacion"></a> <a href="eliminar_compra.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('eliminar','','../imagenes_aplicacion/Botones/Eliminar2.bmp',1)"><img name="eliminar" border="0" src="../imagenes_aplicacion/Botones/Eliminar.bmp" alt="Eliminar datos"></a> <a onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('guardar','','../imagenes_aplicacion/Botones/Guardar1.bmp',1)"><img name="guardar" border="0" src="../imagenes_aplicacion/Botones/Guardar1.bmp" alt="Guardar datos"></a> <a onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('cancelar','','../imagenes_aplicacion/Botones/Cancelar1.bmp',1)"><img name="cancelar" border="0" src="../imagenes_aplicacion/Botones/Cancelar1.bmp" alt="Cancelar"></a> <a href="compras_ini.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('refrescar','','../imagenes_aplicacion/Botones/Refrescar2.bmp',1)"><img name="refrescar" border="0" src="../imagenes_aplicacion/Botones/Refrescar.bmp" alt="Refrescar"></a> <a href="javascript
:popUp('busqueda.asp')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('buscar','','../imagenes_aplicacion/Botones/Buscar2.bmp',1)"><img name="buscar" border="0" src="../imagenes_aplicacion/Botones/Buscar.bmp" alt="Buscar Datos"></a></td>
<td><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('primero','','../imagenes_aplicacion/Botones/Primero2.bmp',1)"> </a> </td>
</tr>
<tr>
<td width="3%"> </td>
<td width="76%" colspan="3">
<%
dim valor
basedatos = Server.MapPath("../conect_db/bd_cl.mdb")
Set conexion = Server.CreateObject("ADODB.Connection")
conexion.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & basedatos & ";"
Set RS = Server.CreateObject("ADODB.RecordSet")
Set Registros = Server.CreateObject("ADODB.RecordSet")
valor = request("id_compra")
if valor="" then
consulta = "SELECT * FROM compras "
else
consulta = "SELECT * FROM compras where id_compra = '"& request("id_compra")&"'"
end if
Set Registros = conexion.Execute(consulta)
%>
</p>
<% if Registros.Eof then %>
<script type="text/javascript">
<!--
var AFS_Account="00323334";
var AFS_Tracker="auto";
var AFS_Server="www3";
var AFS_Page="DetectName";
var AFS_Url="DetectUrl";
// -->
</script>
<SCRIPT LANGUAGE="JavaScript"> alert("No Hay Compras") </SCRIPT>
<% else %>
</td>
<td width="19%"> </td>
</tr>
<tr>
<td width="3%"> </td>
<td width="76%" colspan="3"><div align="center">
<table width="99%" border="1" align="left" bgcolor="#C0C0C0" id="table2">
<tr>
<td width="28" align="center"> </td>
<td align="center" width="124"><b>Folio de compra</b></td>
<td align="center" width="165"><b>Fecha de Compra</b></td>
<td align="center" width="71"><b>Cantidad</b></td>
<td align="center" width="263"><b>Nombre del Material</b></td>
</tr>
<tr>
<%
basedatos = Server.MapPath("../conect_db/bd_cl.mdb")
Set conexion = Server.CreateObject("ADODB.Connection")
conexion.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & basedatos & ";"
Set RS = Server.CreateObject("ADODB.RecordSet")
sSQL = "SELECT compras.* , proveedor.id_proveedor FROM compras , proveedor where compras.id_proveedor = proveedor.id_proveedor order by id_compra"
RS.Open sSQL,conexion ,1,3
%>
<% Do While Not RS.Eof %>
<td width="28">
<p align="center">
<a href="compras_ini.asp?id_compra=<%= RS("id_compra") %>"><img border="0" src="../imagenes_aplicacion/Botones/reg.bmp" width="16" height="18"></a></td>
<td bgcolor="#FFFFFF" width="124"><%=RS("id_compra")%></td>
<td bgcolor="#FFFFFF" width="165"><%=RS("fecha_compra")%></td>
<td bgcolor="#FFFFFF" width="71"><%=RS("cantidad_material")%></td>
<td bgcolor="#FFFFFF" width="263"><%=RS("nombre_material")%></td>
</tr>
<%
RS.MoveNext
Loop
%>
</table></td>
<td width="19%"> </td>
</tr>
<tr>
<td width="3%"> </td>
<td width="16%">Folio de Compra:</td>
<td width="31%"><input disabled type="text" name="id_compra" size="12" value="<%=registros.Fields("id_compra").Value %>"></td>
<td width="30%"> </td>
<td width="19%"> </td> <%end if%>
</tr>
<tr>
<td width="3%"></td>
<td width="16%">Fecha de Compra:</td>
<td width="31%">
<input disabled type="text" name="fecha_compra" size="13" value="<%=registros.Fields("fecha_compra").Value %>"> DD/MM/AAAA</td>
<td width="30%"> </td>
<td width="19%">
</td>
</tr>
<tr>
<td width="3%"> </td>
<td width="16%">Cantidad del Material:</td>
<td width="31%">
<input disabled type="text" name="cantidad_material" size="3" value="<%=registros.Fields("cantidad_material").Va lue %>" ></td>
<td width="50%" colspan="2">ID del Proveedor:<input disabled type="text" name="id_proveedor" size="25" value="<%=registros.Fields("id_proveedor").Value %>"></td>
</tr>
<tr>
<td width="3%"> </td>
<td width="16%">Nombre del Material:</td>
<td width="31%"><input disabled type="text" name="nombre_material" size="16" value="<%=registros.Fields("nombre_material").Valu e %>"></td>
<td width="30%">Unidad de Medida:<input disabled type="text" name="unidad_medida" size="16" value="<%=registros.Fields("unidad_medida").Value %>"></td>
<td width="19%"> </td>
</tr>
<tr>
<td width="3%"> </td>
<td width="16%">Precio del Material </td>
<td width="31%"><input disabled type="text" name="precio_unitario" size="7" value="<%=registros.Fields("precio_unitario").Valu e %>">
C/U</td>
</tr>
<tr>
<td> </td>
<td>
<p align="right">Sub Total</td>
<td>
<input disabled name="sub_total" size="12" value="<%=registros.Fields("sub_total").Value %>" style="float: left"></td>
<td align="left">
<b>TOTAL:</b><input disabled type="text" name="costo_total" size="12" value="<%=registros.Fields("costo_total").Value %>"></td>
<td align="left"> </td>
</tr>
<tr>
<td> </td>
<td colspan="3">
</td>
<td align="left"> </td>
</tr>
<tr>
<td> </td>
<td>
<p align="right">:</td>
<td>
<p align="right">
</td>
<td align="left">
<p>:</td>
<td align="left"> </td>
</tr>
</table>
</div>
<p></p>
</body>
<% Registros.Close
Set Resgistros = Nothing
conexion.Close
Set conexion = Nothing
'RS.Close
'Set RS = Nothing
'Conexion.Close
'Set Conexion = Nothing
%>
</html>
GRACIASPOR SU AYUDA Y SI EQUIEREN VER TODO EL PROYECTO LA DIRECCION ESTA EN
http://www40.brinkster.com/EST44/
NO ME VOY A OLVIDAR DE SU AYUDA EN SUS CREDITOS