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

Pregunta basica

Estas en el tema de Pregunta basica en el foro de ASP Clásico en Foros del Web. Saludos bueno pues no soy muy apegado al asp pero por cuestiones laborales necesito meterme algo en asp y me gustaria enlazar una base de ...
  #1 (permalink)  
Antiguo 07/03/2006, 11:02
 
Fecha de Ingreso: diciembre-2003
Mensajes: 595
Antigüedad: 21 años, 5 meses
Puntos: 1
Pregunta basica

Saludos bueno pues no soy muy apegado al asp pero por cuestiones laborales necesito meterme algo en asp y me gustaria enlazar una base de datos en sql server 2000 y reflejarlo el contenido en los objetos text field, cabe destacar que estoy utilizando dreamweaver 8.

Bueno para empezar les coloco la conexion como segun yo la entendi y mi enlace a las text porfavor tenganme paciencia jeje o es mi fuerte el asp

este es el codigo de mi paguina:



<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>base de datos</title>
</head>

<body>



<%
Dim conn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset


Set conn = Server.CreateObject("ADODB.Connection")
set cmd = Server.CreateObject("ADODB.Command")
set rs = Server.CreateObject("ADODB.Recordset")


conn.ConnectionString = "driver=SQL Server;server=DESARROLLO;uid=;pwd=;database=EXTERN A"

conn.CursorLocation = adUseClient
conn.Open

rs.Open "select * from prueba ", conn, adOpenDynamic, adLockOptimistic


rs("id") = txtid
rs("nombre") = txtnombre
rs("puesto") = txtpuesto
rs("area") = txtarea
rs("telefono") = txttelefono
rs("sueldo") = txtsueldo
rs("fecha_ingreso") = txtfecha
rs("turno") = txtrueno



%>


<form id="form1" name="form1" method="post" action="">
<label>ID
<input type="text" name="txtid" />
</label>
</form>
<form id="form2" name="form2" method="post" action="">
NOMBRE
<input type="text" name="txtnombre" />
</form>
<form id="form3" name="form3" method="post" action="">
PUESTO
<input type="text" name="txtpuesto" />
</form>
<form id="form4" name="form4" method="post" action="">
AREA
<input type="text" name="txtarea" />
</form>
<form id="form5" name="form5" method="post" action="">
<p>TELEFONO
<input type="text" name="txttelefono" /></p>
</form>
<form id="form6" name="form6" method="post" action="">
SUELDO
<input type="text" name="txtsueldo" />
</form>
<form id="form7" name="form7" method="post" action="">
FECHA
<input type="text" name="txtfecha" />
</form>
<form id="form8" name="form8" method="post" action="">
TURNO
<input type="text" name="txtturno" />
</form>
<p>&nbsp;</p>
</body>
</html>



de ante mano les agradesco a los que se allan tomado la molestia en leer mi problema
  #2 (permalink)  
Antiguo 07/03/2006, 11:06
Avatar de Mickel  
Fecha de Ingreso: mayo-2002
Ubicación: Lima, Peru
Mensajes: 4.619
Antigüedad: 23 años
Puntos: 7
bastaria
<form id="form1" name="form1" method="post" action="">
<label>ID
<input type="text" name="txtid" value='<% =rs("id") %>'/>
</label>
NOMBRE
<input type="text" name="txtnombre" value='<% =rs("nombre") %>'/>
PUESTO
<input type="text" name="txtpuesto" value='<% =rs("puesto") %>'/>
AREA
<input type="text" name="txtarea" value='<% =rs("area") %>'/>
<p>TELEFONO
<input type="text" name="txttelefono" value='<% =rs("telefono") %>'/></p>
SUELDO
<input type="text" name="txtsueldo" value='<% =rs("sueldo") %>'/>
FECHA
<input type="text" name="txtfecha" value='<% =rs("fecha") %>'/>
TURNO
<input type="text" name="txtturno" value='<% =rs("turno") %>'/>
</form>
<p>&nbsp;</p>
</body>
</html>
__________________
No tengo firma ahora... :(
  #3 (permalink)  
Antiguo 07/03/2006, 11:12
 
Fecha de Ingreso: diciembre-2003
Mensajes: 595
Antigüedad: 21 años, 5 meses
Puntos: 1
Cita:
Iniciado por Mickel
bastaria
<form id="form1" name="form1" method="post" action="">
<label>ID
<input type="text" name="txtid" value='<% =rs("id") %>'/>
</label>
NOMBRE
<input type="text" name="txtnombre" value='<% =rs("nombre") %>'/>
PUESTO
<input type="text" name="txtpuesto" value='<% =rs("puesto") %>'/>
AREA
<input type="text" name="txtarea" value='<% =rs("area") %>'/>
<p>TELEFONO
<input type="text" name="txttelefono" value='<% =rs("telefono") %>'/></p>
SUELDO
<input type="text" name="txtsueldo" value='<% =rs("sueldo") %>'/>
FECHA
<input type="text" name="txtfecha" value='<% =rs("fecha") %>'/>
TURNO
<input type="text" name="txtturno" value='<% =rs("turno") %>'/>
</form>
<p>&nbsp;</p>
</body>
</html>
gracias por contestar segun tu comentario entonces lo modifique y quedo asi:


<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>base de datos</title>
</head>

<body>



<%
Dim conn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset


Set conn = Server.CreateObject("ADODB.Connection")
set cmd = Server.CreateObject("ADODB.Command")
set rs = Server.CreateObject("ADODB.Recordset")


conn.ConnectionString = "driver=SQL Server;server=DESARROLLO;uid=;pwd=;database=EXTERN A"

conn.CursorLocation = adUseClient
conn.Open



rs.Open "select * from prueba ", conn, adOpenDynamic, adLockOptimistic


%>


<form id="form1" name="form1" method="post" action="">
<label>ID
<input type="text" name="txtid" value='<% =rs("id") %>'/>
</label>
NOMBRE
<input type="text" name="txtnombre" value='<% =rs("nombre") %>'/>
PUESTO
<input type="text" name="txtpuesto" value='<% =rs("puesto") %>'/>
AREA
<input type="text" name="txtarea" value='<% =rs("area") %>'/>
<p>TELEFONO
<input type="text" name="txttelefono" value='<% =rs("telefono") %>'/></p>
SUELDO
<input type="text" name="txtsueldo" value='<% =rs("sueldo") %>'/>
FECHA
<input type="text" name="txtfecha" value='<% =rs("fecha_ingreso") %>'/>
TURNO
<input type="text" name="txtturno" value='<% =rs("turno") %>'/>
</form>


</body>
</html>

si es asi tampoco me core me marca error o si me equivoque me gustaria saberlo de antemano gracias
  #4 (permalink)  
Antiguo 07/03/2006, 11:25
Avatar de trasgukabi  
Fecha de Ingreso: septiembre-2004
Mensajes: 2.749
Antigüedad: 20 años, 8 meses
Puntos: 18
varias cosas:

-en la cabecera indicas que la página es en jscript y tú quieres hacerlo en vbscript

-ese tipo de declaraciones de variables son de visual basic

-si quieres usar las constantes de cursores, etc (aduseclient,adopendynamic...) debes incluir una de las mejores ideas de microsoft: el archivo adovbs.inc
  #5 (permalink)  
Antiguo 07/03/2006, 11:27
Avatar de El_Metallick  
Fecha de Ingreso: noviembre-2002
Ubicación: Santiago, Chile
Mensajes: 1.718
Antigüedad: 22 años, 6 meses
Puntos: 16
si quieres reflejar todos en forma de lista tienes que hacer un ciclo, si no tienes que especificar en tu consulta el id que quieres mostrar, un ejemplo de cada uno:

Ciclo:
Código:
<%
Do While Not rs.Eof
%>
 <form id="form<% = rs("id") %>" name="form<% = rs("id") %>" method="post" action="">
 <label>ID
 <input type="text" name="txtid<% = rs("id") %>" value='<% =rs("id") %>'/>
 </label>
 NOMBRE
 <input type="text" name="txtnombre<% = rs("id") %>" value='<% =rs("nombre") %>'/>
 PUESTO
 <input type="text" name="txtpuesto<% = rs("id") %>" value='<% =rs("puesto") %>'/>
 AREA
 <input type="text" name="txtarea<% = rs("id") %>" value='<% =rs("area") %>'/>
 <p>TELEFONO
 <input type="text" name="txttelefono<% = rs("id") %>" value='<% =rs("telefono") %>'/></p>
 SUELDO
 <input type="text" name="txtsueldo<% = rs("id") %>" value='<% =rs("sueldo") %>'/>
 FECHA
 <input type="text" name="txtfecha<% = rs("id") %>" value='<% =rs("fecha_ingreso") %>'/>
 TURNO
 <input type="text" name="txtturno<% = rs("id") %>" value='<% =rs("turno") %>'/>
</form>
<%
rs.MoveNext
Loop
%>
id fija:
Código:
  <%
    Dim conn As ADODB.Connection
    Dim cmd As ADODB.Command
    Dim rs As ADODB.Recordset  
 
   
    Set conn = Server.CreateObject("ADODB.Connection")  
    set cmd = Server.CreateObject("ADODB.Command")
    set rs = Server.CreateObject("ADODB.Recordset")
    
    
 conn.ConnectionString = "driver=SQL Server;server=DESARROLLO;uid=;pwd=;database=EXTERN A"
    
      conn.CursorLocation = adUseClient
      conn.Open
 	 
       
 
 rs.Open "select * from prueba where id = "2"", conn, adOpenDynamic, adLockOptimistic
  
 
 %>
Espero haber sido claro... saludos y suerte
__________________
Haz la guerra en la cama y el amor donde se te de la gana...
El tiempo es el mejor maestro, lo único malo es que te mata...¡¡Aprovecha tu tiempo!!
  #6 (permalink)  
Antiguo 07/03/2006, 11:33
 
Fecha de Ingreso: diciembre-2003
Mensajes: 595
Antigüedad: 21 años, 5 meses
Puntos: 1
Cita:
Iniciado por El_Metallick
si quieres reflejar todos en forma de lista tienes que hacer un ciclo, si no tienes que especificar en tu consulta el id que quieres mostrar, un ejemplo de cada uno:

Ciclo:
Código:
<%
Do While Not rs.Eof
%>
 <form id="form<% = rs("id") %>" name="form<% = rs("id") %>" method="post" action="">
 <label>ID
 <input type="text" name="txtid<% = rs("id") %>" value='<% =rs("id") %>'/>
 </label>
 NOMBRE
 <input type="text" name="txtnombre<% = rs("id") %>" value='<% =rs("nombre") %>'/>
 PUESTO
 <input type="text" name="txtpuesto<% = rs("id") %>" value='<% =rs("puesto") %>'/>
 AREA
 <input type="text" name="txtarea<% = rs("id") %>" value='<% =rs("area") %>'/>
 <p>TELEFONO
 <input type="text" name="txttelefono<% = rs("id") %>" value='<% =rs("telefono") %>'/></p>
 SUELDO
 <input type="text" name="txtsueldo<% = rs("id") %>" value='<% =rs("sueldo") %>'/>
 FECHA
 <input type="text" name="txtfecha<% = rs("id") %>" value='<% =rs("fecha_ingreso") %>'/>
 TURNO
 <input type="text" name="txtturno<% = rs("id") %>" value='<% =rs("turno") %>'/>
</form>
<%
rs.MoveNext
Loop
%>
id fija:
Código:
  <%
    Dim conn As ADODB.Connection
    Dim cmd As ADODB.Command
    Dim rs As ADODB.Recordset  
 
   
    Set conn = Server.CreateObject("ADODB.Connection")  
    set cmd = Server.CreateObject("ADODB.Command")
    set rs = Server.CreateObject("ADODB.Recordset")
    
    
 conn.ConnectionString = "driver=SQL Server;server=DESARROLLO;uid=;pwd=;database=EXTERN A"
    
      conn.CursorLocation = adUseClient
      conn.Open
 	 
       
 
 rs.Open "select * from prueba where id = "2"", conn, adOpenDynamic, adLockOptimistic
  
 
 %>
Espero haber sido claro... saludos y suerte
gracias por la erspuesta pero no lo quisiera en lista solo me gustaria llamar al primer registro ya despues haria una busqueda pero lo que sige sin hacerme es el enlace no se si mi conexion este bien y mi enlace a las text tambien




<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>base de datos</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #006699;
}
-->
</style></head>

<body>



<%
Dim conn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset


Set conn = Server.CreateObject("ADODB.Connection")
set cmd = Server.CreateObject("ADODB.Command")
set rs = Server.CreateObject("ADODB.Recordset")

conn.ConnectionString = "driver=SQL Server;server=DESARROLLO;uid=;pwd=;database=EXTERN A"

conn.CursorLocation = adUseClient
conn.Open



rs.Open "select * from prueba ", conn, adOpenDynamic, adLockOptimistic




%>

<form id="form1" name="form1" method="post" action="">
<label>ID
<input type="text" name="txtid" value='<% =rs("id") %>'/>
</label>
NOMBRE
<input type="text" name="txtnombre" value='<% =rs("nombre") %>'/>
PUESTO
<input type="text" name="txtpuesto" value='<% =rs("puesto") %>'/>
AREA
<input type="text" name="txtarea" value='<% =rs("area") %>'/>
<p>TELEFONO
<input type="text" name="txttelefono" value='<% =rs("telefono") %>'/></p>
SUELDO
<input type="text" name="txtsueldo" value='<% =rs("sueldo") %>'/>
FECHA
<input type="text" name="txtfecha" value='<% =rs("fecha") %>'/>
TURNO
<input type="text" name="txtturno" value='<% =rs("turno") %>'/>
</form>

</body>
</html>
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 17:32.