0
我有這個代碼插入數據到數據庫。在我提交之前,我想確保數據輸入成功,然後提交其他回滾兩個插入。SQLconnection不支持並行事務
try {
statement one commit;
statement two commit;
}
catch {
error message
statement 1 Rollback();
statement 2 Rollback();
}
finally {
if (con.State == Con.Open)
con.Close();
}
你的問題有點不清楚,標題混淆爲1)你沒有在psuedocode中創建一個數據庫事務,並且2)這些語句沒有並行運行。 – stuartd
將所有插入腳本放入try {}中,因爲如果嘗試失敗,它們不會並行運行,它只會轉到'catch',您基本上會說「嘗試插入此數據,但如果失敗,則抓住它」。 –
也許看看[在.net中的事務](http://stackoverflow.com/questions/224689/transactions-in-net) – stuartd