Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/09/2004, 09:46
elianni
 
Fecha de Ingreso: junio-2004
Mensajes: 10
Antigüedad: 20 años, 11 meses
Puntos: 0
Conexion A Bd Sql 7 Con Asp

Hola tengo un gran problema, quiero conectarme a una Bd que he creado en SQL se llama cliente y esta en la particion C: de mi HD; en la partición D: de mi HD tengo mis archivos web, en el IIS he creado un directorio virtual con la ruta de mis archivos que estan en D, ahora tengo los archivos conexion.asp e inserta.asp, y el index.htm que me llama al inserta.

El código de conexion.asp es el sgte:
<%
strcade = "Provider=SQLOLEDB.1; Persist Security Info=False; Initial Catalog=prueba; Data Source=local; User Id=sa; PASSWORD=" ";"

set conn = server.createobject("adodb.connection")
conn.ConnectionTimeout = 1000
conn.CommandTimeout = 1000

conn.Open(strcade)

err.Clear
On error resume next

if err.number <> 0 or err.description <> "" then
conn.Close
conn = nothing
Response.Write(err.Description)

Response.End()
end if
%>


El código de inserta.asp es el sgte:

<!--#include file="conexion.asp"-->
<%
If Request("txtNombre") <> empty and Request("txtApellido") <> empty and Request("txtEdad") <> empty and Request("radSexo") <> empty Then

sql = "insert into cliente select '" & cstr(Request("txtNombre")) & "', '" & cstr(Request("txtApellido")) & "'," & cint(Request("txtEdad")) & ",'" & Request("radSexo") & "'"

Set rsInserta = Server.CreateObject("adodb.recordset")

rsInserta.Open sql,conn

rsInserta.Close
set rsInserta = nothing

Mensaje = "Felicitaciones se insertó el registro..!"
End if

%>
<html>

<head>

<title>Inserta Clientes</title>
<style fprolloverstyle>A:hover {color: red; font-weight: bold}
</style>
<script language=javascript>

function f_Grabar() {
document.frmCliente.submit()
}

function f_Cancelar() {
document.frmCliente.txtNombre.value=""
document.frmCliente.txtApellido.value=""
document.frmCliente.txtEdad.value=""
}

function f_Mensaje() {
if('<%=Mensaje%>'!='') {
alert('<%=Mensaje%>')
}
}

</script>
</head>
<body onload="f_Mensaje()">
<form name="frmCliente" id=frmCliente action=inserta.asp method=post>
<center>
<table border="0" width="445" cellspacing="0" cellpadding="0" style="border-style: solid; border-width: 1" ID="Table1">
<tr>
<td width="443" colspan="2"><b>Ingreso de Clientes</b></td>
</tr>
<tr>
<td width="99" style="border-style: solid; border-width: 1">Nombres</td>
<td width="342" style="border-style: solid; border-width: 1"><input type="text" name="txtNombre" size="40" ID="txtNombre"></td>
</tr>
<tr>
<td width="99" style="border-style: solid; border-width: 1">Apellidos</td>
<td width="342" style="border-style: solid; border-width: 1"><input type="text" name="txtApellido" size="40" ID="txtApellido"></td>
</tr>
<tr>
<td width="99" style="border-style: solid; border-width: 1">Edad</td>
<td width="342" style="border-style: solid; border-width: 1"><input type="text" name="txtEdad" size="5" ID="txtEdad"></td>
</tr>
<tr>
<td width="99" style="border-style: solid; border-width: 1">Sexo</td>
<td width="342" style="border-style: solid; border-width: 1"><input type="radio" value="M" checked name="radSexo" ID="radSexo">&nbsp;Masculino&nbsp;&nbsp;<input type="radio" value="F" checked name="radSexo" ID="radSexo">&nbsp;Femenino</td>
</tr>
<tr>
<td width="441" style="border-style: solid; border-width: 1" colspan="2" align="center">
<input type="button" value="Grabar" name="btnEnviar" ID="btnEnviar" onclick="f_Grabar()">&nbsp;<input type="reset" value="Cancelar" name="btnCancelar" ID="btnCancelar" onclick="f_Cancelar()"></td>
</tr>
</table>
<center>
</form>
</body>
</html>


Al momento de hacer el llamado a la pag. inserta.asp me genera el siguiente error:

Tipo de error:
Error de compilación de Microsoft VBScript (0x800A0401)
Se esperaba un final de instrucción
/prueba/conexion.asp, line 8, column 127
strcade = "Provider=SQLOLEDB.1; Persist Security Info=False; Initial Catalog=prueba; Data Source=local; User Id=sa; PASSWORD=" ";"
------------------------------------------------------------------------------------------------------------------------------^


Tipo de explorador:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

Página:
GET /prueba/inserta.asp



podrían ayudarme a saber que es lo que sucede porque es un ejemplo de mis estudios y no me sale, podrían ayudarme ya que recien estoy entrando a este tema y no lo entiendo muy bien.

Gracias

[email protected]