Como tengo 2 tablas relacionadas con un id autonumerico intento poner el valor en una variable. El primer asp va bien:
Cita:
Este asp llama a otro para guadar la actividad de la empresa con la IdEmpresa q se ha guardado en la variable Id_New. O eso es lo q yo pretendo q haga.<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>(Type a title for your page here)</title>
<%@ LANGUAGE=JScript %>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
<form action="OtrasActividades.asp" METHOD =POST>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<%
conexion= new ActiveXObject("ADODB.Connection")
registro1=new ActiveXObject("ADODB.Recordset")
conexion.Open("datos")
x="select * from 902_DATOS_GENERALES where Empresa='"+Request.Form("empresa")+"'"
registro1.Open (x, conexion, 3, 0x0002)
if(registro1.EOF)
{
registro1.Addnew ()
registro1("Empresa") = Request.form ("empresa")
registro1("Direccion") = Request.form ("direccion")
registro1.Update()
Response.Write("Datos correctos")
}
else
{
Response.Write("Nombre de la empresa no válida")
}
registro1.close()
conexion.close()
conexion5= new ActiveXObject("ADODB.Connection")
registro5=new ActiveXObject("ADODB.Recordset")
conexion5.Open ("datos")
Fnc_Sql = "Select @@IDENTITY as IdEmpresa"
registro5.Open (Fnc_Sql, conexion5, 3, 0x0002)
Id_New = registro5("IdEmpresa")
registro5.Close()
conexion5.close()
%>
<center>
<h3>OTRAS ACTIVIDADES DE LA EMPRESA</h3>
</center>
<br>
<br>
<h3>Descripción de otras actividades
<input type=text name="desactividades">
<br>
<input type="submit" value="ALTA">
</body>
</html>
<html>
<head>
<title>(Type a title for your page here)</title>
<%@ LANGUAGE=JScript %>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
<form action="OtrasActividades.asp" METHOD =POST>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<%
conexion= new ActiveXObject("ADODB.Connection")
registro1=new ActiveXObject("ADODB.Recordset")
conexion.Open("datos")
x="select * from 902_DATOS_GENERALES where Empresa='"+Request.Form("empresa")+"'"
registro1.Open (x, conexion, 3, 0x0002)
if(registro1.EOF)
{
registro1.Addnew ()
registro1("Empresa") = Request.form ("empresa")
registro1("Direccion") = Request.form ("direccion")
registro1.Update()
Response.Write("Datos correctos")
}
else
{
Response.Write("Nombre de la empresa no válida")
}
registro1.close()
conexion.close()
conexion5= new ActiveXObject("ADODB.Connection")
registro5=new ActiveXObject("ADODB.Recordset")
conexion5.Open ("datos")
Fnc_Sql = "Select @@IDENTITY as IdEmpresa"
registro5.Open (Fnc_Sql, conexion5, 3, 0x0002)
Id_New = registro5("IdEmpresa")
registro5.Close()
conexion5.close()
%>
<center>
<h3>OTRAS ACTIVIDADES DE LA EMPRESA</h3>
</center>
<br>
<br>
<h3>Descripción de otras actividades
<input type=text name="desactividades">
<br>
<input type="submit" value="ALTA">
</body>
</html>
Aqui esta el codigo del otro asp para guardar los datos en otra tabla.
Cita:
Pero me sale este error: <!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>(Type a title for your page here)</title>
<%@ LANGUAGE=JScript %>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<%
conexion4=new ActiveXObject("ADODB.Connection")
registro4=new ActiveXObject("ADODB.Recordset")
conexion4.Open ("datos")
x="select * from 903_OTRAS_ACTIVIDADES where IdEmpresa='"+Request.Form("Id_New")+"'"
registro4.Open (x, conexion4, 3, 0x0002)
if(registro4.EOF)
{
registro4.Addnew ()
registro4("DesOtrasActividades") = Request.form ("desactividades")
registro4("IdEmpresa") = Request.form("Id_New")
registro4.Update()
Response.Write("Datos correctos")
}
else
{
Response.write ("Error")
}
registro4.close()
conexion4.close()
%>
</body>
</html>
<html>
<head>
<title>(Type a title for your page here)</title>
<%@ LANGUAGE=JScript %>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<%
conexion4=new ActiveXObject("ADODB.Connection")
registro4=new ActiveXObject("ADODB.Recordset")
conexion4.Open ("datos")
x="select * from 903_OTRAS_ACTIVIDADES where IdEmpresa='"+Request.Form("Id_New")+"'"
registro4.Open (x, conexion4, 3, 0x0002)
if(registro4.EOF)
{
registro4.Addnew ()
registro4("DesOtrasActividades") = Request.form ("desactividades")
registro4("IdEmpresa") = Request.form("Id_New")
registro4.Update()
Response.Write("Datos correctos")
}
else
{
Response.write ("Error")
}
registro4.close()
conexion4.close()
%>
</body>
</html>
Cita:
La linea 20 es donde hace la conexion: Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][Controlador ODBC Microsoft Access] No coinciden los tipos de datos en la expresión de criterios.
/OtrasActividades.asp, línea 20
[Microsoft][Controlador ODBC Microsoft Access] No coinciden los tipos de datos en la expresión de criterios.
/OtrasActividades.asp, línea 20
Cita:
Habia pensado en cambiar el valor del id en la tabla donde no es clave. Pero si no es númerico no deja relacionarla. X eso no comprendo el error.registro4.Open (x, conexion4, 3, 0x0002)
¿Alguien me puede ayudar? Muchas gracias.