Link to home
Create AccountLog in
Avatar of TonyReba
TonyRebaFlag for United States of America

asked on

How do I check for succesfully inserted and show message formview?

I am trying to write a code to check wheter the insertion into an access database was succesflly, and if so display a succesfully message on my label control,  

How would I do that??
Protected Sub FormView1_ItemCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.ItemCreated

        ' Perform any additional processing, 
        ' such as setting a status label after the operation.        
        Label3.Text = " Information updated successfully!"

    End Sub

Open in new window

Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Are you using an insert button?  The FormView has the ItemInserting and ItemInserted events that is raised when an Insert button is pressed.

FormView.ItemInserted Event
Avatar of TonyReba


but i want to check on the actual database if the data was  inserted??////
If you want to check the actual database, then you need a different construct, where you read the record to make sure that the record was actually created.
Yes , is there any way I can do this? Meabe a try catch block?
If I understand your requirement correctly, you are going to have to put in something that actually goes out to the database, and attempts to find the record by the primary key.  Otherwise, the ItemInserted event should be after the record is written to the database.  The only problem with the ItemInserted event, is that you don't know if it was physically written to the database or not.
Hi what would you suggest to make sure the record was inserted correctly?
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account