Ver Mensaje Individual
  #5 (permalink)  
Antiguo 31/01/2003, 10:11
Avatar de vamp_02
vamp_02
 
Fecha de Ingreso: febrero-2002
Ubicaci髇: Santiago de Chile
Mensajes: 367
Antig黣dad: 23 a駉s
Puntos: 0
Henrry, ya logre que se insertara un registro (en oracle), pero ahora necesito hacer un par de validaciones:

.- Que si el Registro existe

supongamos:

Tengo el Form, Login y password, que tengo que poner si el usuario trata de inscribirse y su login ya existe.

<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="aa.aspx.vb" Inherits="TCCUOTAS.aa" Debug="true"%>
<HTML>
<script runat="server">
Sub addusu_click(obj As object, e As eventargs)
if ispostback() then
Dim objConn As New OleDbConnection ("Provider=MSDAORA.1;Password=clcabrer;User ID=clcabrer;Data Source=ccabrera")
If(Page.IsValid)
Dim sSQL, Resul as string
sSQL = "Insert into usu (USUARIO,PASSWORD) values ('" & login.text & "','" & password.text & "')"
Dim objCmd As New OleDbCommand (sSQL, objConn)
objConn.open
resul= objCmd.ExecuteNonQuery()
if resul="" then
response.write ("Registro agregado")
else
response.write ("Registro no agregado")
End if
else
response.write ("Registro no agregado")
end if
end if
obj.Connection.Close()
End sub
</script>
<body>
<form id="Form1" runat="server">
Insertar nuevo cliente:
<br>
<br>
<hr>
Nombre:
<ASP:TEXTBOX id="login" runat="Server" AutoPostBack="True"></ASP:TEXTBOX><br>
password:
<ASP:TEXTBOX id="password" runat="Server"></ASP:TEXTBOX><br>
<ASP:BUTTON id="Enviar" onclick="addusu_click" runat="Server" Text="Enviar"></ASP:BUTTON><br>
<hr>
</form>
</body>
</HTML>


Este cogi no me sirve, porque me devuelve este error.


ORA-00001: restricci髇 鷑ica (CLCABRER.PK_USU) violada
Descripci贸n: Excepci贸n no controlada al ejecutar la solicitud Web actual. Revise el seguimiento de la pila para obtener m谩s informaci贸n acerca del error y d贸nde se origin贸 en el c贸digo.

Detalles de la excepci贸n: System.Data.OleDb.OleDbException: ORA-00001: restricci髇 鷑ica (CLCABRER.PK_USU) violada


Como lo hago para manejar este error, que no me aprezca en pantalla, pero si que aparezca un mensaje "Error:Usuario ya existe"

Algo asi.


Gracias