Click here to Skip to main content
16,012,061 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
See more:
VB
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Try
            If IsPostBack() Then
                Dim objConn As New SqlConnection(WebConfigurationManager.ConnectionStrings("cnxCurso").ConnectionString)
                Dim sSQL, Resul As String
                sSQL = "Insert into dbo.actor (dpi, nombre, comunidad, fecha, genero, usuario) values ('" & txtdpi.Text & "', '" & txtactor.Text & "', '" & txtcomunidad.Text & "', '" & txtfecha.Text & "', '" & genero.Text & "', '" & txtusuario.Text & "')"
                Dim objCmd As New SqlCommand(sSQL, objConn)
                objConn.Open()
                Resul = objCmd.ExecuteNonQuery
                If Resul Then
                    'MsgBox("Se ha agregado correctamente el registro")
                    respuesta.Visible = True
                    respuesta.Text = "Registro agregado"
                    Response.Redirect("mantenimiento.aspx", True)
                    objConn.Close()
 
                Else
                    'MessageBox.Show("No se agregado correctamente el registro")
                    respuesta.Visible = True
                    respuesta.Text = "Registro no agregado"
 
                End If
            End If
        Catch ex As SqlException
 
        End Try
        respuesta.Text = "Registro agregado"
 

    End Sub
Posted
Updated 14-Apr-13 18:05pm
v2

1 solution

The Easy way is to read the database 2. compare results 3 if exist do something

for example we have database called ice_cream.mdb that it have one record chocolatte...
so when u start the application it should read the records and save all the record somewhere for example in a file or something else... so when u will add new record it should read the file if record exist... when a name of record exist show a messagebox and terminate insertion! if not exist execute the query... sorry for my low english.. hope i helped you...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900