If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > ASP.NET + MySQL 4 + Transactions

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-06-07, 11:34
PolarBear2k PolarBear2k is offline
Registered User
 
Join Date: Jun 2005
Posts: 79
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
Reply With Quote
  #2 (permalink)  
Old 01-07-07, 17:58
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
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).
Reply With Quote
  #3 (permalink)  
Old 01-08-07, 00:22
PolarBear2k PolarBear2k is offline
Registered User
 
Join Date: Jun 2005
Posts: 79
I thought of that too. Thanks for clearing that up.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On