Foros del Web » Programando para Internet » ASP Clásico »

nueva ayuda con codigo x favor

Estas en el tema de nueva ayuda con codigo x favor en el foro de ASP Clásico en Foros del Web. Tengo el siguiente codigo , es de un directorio con subdirectorio , el tema es que cuando quiero agregar subcategorias me dice que la subcategoria ...
  #1 (permalink)  
Antiguo 23/03/2005, 13:23
(Desactivado)
 
Fecha de Ingreso: agosto-2002
Mensajes: 1.458
Antigüedad: 22 años, 9 meses
Puntos: 0
Pregunta nueva ayuda con codigo x favor

Tengo el siguiente codigo , es de un directorio con subdirectorio , el tema es que cuando quiero agregar subcategorias me dice que la subcategoria ya existe pero esta no existe , lo que pienso que debe ser que no esta pasando bien el id de la categoria a la subcategoria fijensen donde puse las /// ahi es donde queda el programa y me da esa leyenda el tema es que no se como arreglarlo para que pase bien la subcategoria


<%
if Session("Admin") = False or IsNull (Session("Admin")) = True then
Response.Redirect("login.asp")
end if
%>
<%
Dim Conn ' Open Database Connection
Dim RS ' Open Record Set
Dim SQL ' SQL statement
Dim DSN ' DSN Less Connection

DSN = "DBQ=" & Server.Mappath("category.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
Set RS = Server.CreateObject("ADODB.Recordset")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open DSN
if Request.Form("Add") = "Add" Then
SQLValid = "SELECT subcatName from subcategory "
set RSValid=server.createobject("ADODB.Recordset")
RSValid.open SQLValid,Conn,3,1
if Request.Form("subcatName") = "" Then
Response.Redirect("error.asp?Error=Please enter the sub category name")
End if
if RSValid.recordcount > 0 Then
Response.Redirect("error.asp?Error=That Subcategory already existed") ////
End if
subcatName = Request.Form("subcatName")
catID = Request.Form("catID")
subcatDesc = Request.Form("subcatDesc")
SQLAdd = "INSERT INTO subcategory(catID,subcatName,subcatDesc)Values('"
SQLAdd = SQLAdd &catID&"','"&subcatName&"','"&subcatDesc&"')"
Conn.Execute(SQLAdd)
Response.Redirect("done.asp?Msg=Record has been added to database")
Else
SQL = "SELECT * FROM category order by catName"
RS.Open SQL, Conn
%>

la parte del formulario que envia es el siguiente :

category name :</div></td>
<td><input name="subcatName" type="text" id="subcatName">

</td>
</tr>
<tr>
<td width="150" class="bodyBold8">
<div align="right">Category
: </div></td>
<td><select name="subID" id="select" >
<%
do while not RS.eof
response.write "<option value=" & RS(0) & ">" & RS(1) & "</option>"
RS.movenext
loop
%>
</select></td>
</tr>
<tr>
<td width="150" valign="top" class="bodyBold8">
<div align="right">Subcat Description :
</div></td>
<td><textarea name="subcatDesc" rows="6" id="subcatDesc"></textarea></td>
</tr>
<tr>
<td width="150">&nbsp;</td>
<td><input name="Add" type="submit" id="Add" value="Add">
<input type="reset" name="Submit3" value="Reset"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>
</form></td>
</tr>

Última edición por hugorei; 23/03/2005 a las 13:25
  #2 (permalink)  
Antiguo 23/03/2005, 20:09
(Desactivado)
 
Fecha de Ingreso: agosto-2002
Mensajes: 1.458
Antigüedad: 22 años, 9 meses
Puntos: 0
por favor si alguien me puede ayudar estaria agradecido sigo sin saber como solucionar este error - gracias
  #3 (permalink)  
Antiguo 24/03/2005, 09:43
Avatar de AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 24 años, 2 meses
Puntos: 535
lo estube revisando y la lógica es bastante simple... así que si te dice que esa categoría existe, es que realmente existe (no le veo otra).

Debugueá y compará con los datos realmente almacenados en la base de datos:




<%
if Session("Admin") = False or IsNull (Session("Admin")) = True then
Response.Redirect("login.asp")
end if
%>
<%
Dim Conn ' Open Database Connection
Dim RS ' Open Record Set
Dim SQL ' SQL statement
Dim DSN ' DSN Less Connection

DSN = "DBQ=" & Server.Mappath("category.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
Set RS = Server.CreateObject("ADODB.Recordset")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open DSN
if Request.Form("Add") = "Add" Then
SQLValid = "SELECT subcatName from subcategory "
set RSValid=server.createobject("ADODB.Recordset")
RSValid.open SQLValid,Conn,3,1

Response.Write SQLValid & "<br>"
Response.Write RSValid.Recordcount & "<br>"
Response.End


if Request.Form("subcatName") = "" Then
Response.Redirect("error.asp?Error=Please enter the sub category name")
End if
if RSValid.recordcount > 0 Then
Response.Redirect("error.asp?Error=That Subcategory already existed") ////
End if
subcatName = Request.Form("subcatName")
catID = Request.Form("catID")
subcatDesc = Request.Form("subcatDesc")
SQLAdd = "INSERT INTO subcategory(catID,subcatName,subcatDesc)Values('"
SQLAdd = SQLAdd &catID&"','"&subcatName&"','"&subcatDesc&"')"
Conn.Execute(SQLAdd)
Response.Redirect("done.asp?Msg=Record has been added to database")
Else
SQL = "SELECT * FROM category order by catName"
RS.Open SQL, Conn
%>

la parte del formulario que envia es el siguiente :

category name :</div></td>
<td><input name="subcatName" type="text" id="subcatName">

</td>
</tr>
<tr>
<td width="150" class="bodyBold8">
<div align="right">Category
: </div></td>
<td><select name="subID" id="select" >
<%
do while not RS.eof
response.write "<option value=" & RS(0) & ">" & RS(1) & "</option>"
RS.movenext
loop
%>
</select></td>
</tr>
<tr>
<td width="150" valign="top" class="bodyBold8">
<div align="right">Subcat Description :
</div></td>
<td><textarea name="subcatDesc" rows="6" id="subcatDesc"></textarea></td>
</tr>
<tr>
<td width="150">&nbsp;</td>
<td><input name="Add" type="submit" id="Add" value="Add">
<input type="reset" name="Submit3" value="Reset"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>
</form></td>
</tr>
__________________
...___...
  #4 (permalink)  
Antiguo 24/03/2005, 12:43
(Desactivado)
 
Fecha de Ingreso: agosto-2002
Mensajes: 1.458
Antigüedad: 22 años, 9 meses
Puntos: 0
gracias AL ZUWAGA lo reviso y te aviso , gracias por tu ayuda -
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:52.