Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005
    Posts
    79

    Unanswered: ASP.NET + MySQL 4 + Transactions

    Hi,

    I want to insert a row into a table but I need to check if that row already exists based on a column like a persons name. So I need to have 2 statements one for the check and another for the insert. Is the only way I can be sure that the information I received from the first statement that checks if that person name exists is to use a transaction, as it basically tells the database to execute these statements one after another?
    If two or more users try to insert the same person and I don't have transactions then I can't rely on the order of how the statements will be executed on the database. Is this correct? Would there be a different way to control the order without using transactions in ASP.NET 1.1?

    Thanks

  2. #2
    Join Date
    Mar 2004
    Posts
    480
    you don't need transactions. you need a single insert statement. make a field that you are inserting into unique and then either do an insert and deal with the failed messages where duplicate information exists, or do an INSERT ON DUPLICATE UPDATE if that is appropriate ( a new user would get inserted, an existing one would have info in their row updated).

  3. #3
    Join Date
    Jun 2005
    Posts
    79
    I thought of that too. Thanks for clearing that up.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •