Hi guys,
I am using a details view control for users to enter leave details, I have set some conditions of which if the user does not meet them then a label is displayed to tell him/her what the problem is.
But after displaying the label, I realized that the information is still entered in the table. I have tried closing the connection, exiting the sub but both are not working.
What should I do?

If days <= 1 Then
            Label3.Visible = True
            lvconn.Close()
            Exit Sub
        ElseIf days >= 30 Then
            Label4.Visible = True
            lvconn.Close()
            Exit Sub
        Else
            Response.Redirect("Leave_details.aspx")
        End If

You test is being done after the details view is posting to the server, which in turn is posting things into the database. You'll need some form of test before the postback, or to manually handle the database access. You could do a custom validator on the client side, or some javascript. Otherwise, you could handle all your database calls directly from your codebehind, making the use of the asp.net data access control nearly useless to you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.