locked
How to check if record is added in access database RRS feed

  • Question

  • User-1660374330 posted

    Hi,

    I'm trying to put a registration page together in Visual Web Designer.

    I would like to send a confirmation Email after someone is leaving his registration data and pressing the INSERT button.

    The key fields in my database are: Email, Name, Surname, Address

    Before I send the confirmation Email I would like to check if the email value entered in the form is realy added to the database.

    Please for help in this matter. I was copy past already some C code in my page, therefore it will be fine if the code can be in C.

    Again, I need help to:

    - checking if record is realy added to database after pressing INSERT button

    - setup the confirmation Email


    Thank you in advance.

    Frenkie

    Thursday, August 26, 2010 2:37 PM

Answers

All replies

  • User-821857111 posted

    If your table has an Autonumber Primary Key, you can use @@IDENTITY to retrieve the new record's ID value: http://www.mikesdotnetting.com/Article/54/Getting-the-identity-of-the-most-recently-added-record. If that's returned, you can be sure the record was added.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 26, 2010 3:18 PM
  • User-1199946673 posted

    If your table has an Autonumber Primary Key, you can use @@IDENTITY to retrieve the new record's ID value: http://www.mikesdotnetting.com/Article/54/Getting-the-identity-of-the-most-recently-added-record. If that's returned, you can be sure the record was added.

     

    Yes, but if you don't need to retrieve the ID, it's easier to ctach the return value of the ExecuteNonQuery Function, which returns the number of affected records, and if this is 1, you're sure that the record is added to the table, without making an axtra database call.

    Thursday, August 26, 2010 3:33 PM
  • User-821857111 posted

    Yes, but if you don't need to retrieve the ID, it's easier to ctach the return value of the ExecuteNonQuery Function, which returns the number of affected records, and if this is 1, you're sure that the record is added to the table, without making an axtra database call.

    Actually, now that I have read the question a bit more closely, I would get the Identity value, and then query for the associated email address. It would be nice if you could do it all in one go, but that's a limitation of Access.


    Thursday, August 26, 2010 4:36 PM
  • User-1828494216 posted

    Again, I need help to:

    - checking if record is realy added to database after pressing INSERT button

    Thank you in advance.

    Frenkie



    I think that if the record is inserted there will be no error, so i wouldn't check @@IDENTITY or returning row number affected by ExecuteNonQuery.

    Maybe if you realy want to have some sort of confirm, i would write insert query that returns the email.

    I would put RegularExpression Validator instead. But even that can be a false mail. Who can confirm that mymail@gmail.com is realy my name? But for first validation it's ok.

    Next i would do as you said. Send confirm mail so that way you can be sure it's the right email.



    Again, I need help to:

    - setup the confirmation Email

    Thank you in advance.

    Frenkie

    <strike>This is how to setup email in asp: http://www.powerasp.com/content/new/sending_email_cdosys.asp</strike> Not the recommended way

    Thursday, August 26, 2010 5:15 PM
  • User-821857111 posted

    No - that's how to set up email in Classic ASP, whereas this forum covers ASP.NET. That's totally different. In ASP.NET, we use System.Net.Mail to send email. Here are some samples: http://www.systemnetmail.com/faq/3.aspx


    Thursday, August 26, 2010 5:46 PM
  • User-1828494216 posted

    That is True, i completly forgot about that... But! I belive that cdosys works in asp.net, doesn't it?

    But yeah, your suggestion is definetly better.


    Thank you for your correction.

    Thursday, August 26, 2010 6:07 PM
  • User-821857111 posted

    I belive that cdosys works in asp.net, doesn't it?

    It works, and was indeed the basis of System.Web.Mail before it was deprecated in favour of System.Net.Mail. The latter is completely managed code instead of being a wrapper around an old COM component, which is why using CDOSYS is not recommended.


    Thursday, August 26, 2010 6:31 PM
  • User-1660374330 posted

    As I wrote;

    I would like to send the Email after checking if record is really added.

    I have not Autonumber in my Table. The primary key is Email.


    We take the enetered Email  in the Texbox and compare it with records in the database.

    Then if record is added we send Email to the entered Email in Textbox. But this all

    functions must be inside one page. Please in C



    Friday, August 27, 2010 1:41 AM
  • User-821857111 posted

    But this all

    functions must be inside one page. Please in C

    OK. What have you got so far? Is it causing errors? Or are you hoping someone here does your homework for you?



    Friday, August 27, 2010 3:18 AM
  • User-1660374330 posted

    I have everything working except checking for added record and sending confirmation mail.

    Friday, August 27, 2010 1:28 PM
  • User-1199946673 posted

    I have everything working except checking for added record and sending confirmation mail.

     

    And now you expect us to give you the code?

    Friday, August 27, 2010 1:43 PM
  • User-1660374330 posted

    no, but to help me how to do that

    Saturday, August 28, 2010 1:18 AM
  • User-1660374330 posted

    Couse I have the INSERT button in my Form I was thinking if I should open a new url on click. In new window I could than check if the record was added and send email?


    Saturday, August 28, 2010 1:23 AM