⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 17.8.txt

📁 《Microsoft Visual C# .NET 2003开发技巧大全》源代码
💻 TXT
字号:
Listing 17.8 Using TransactionOption for Transactions
[WebMethod(Description=”This is a transaction sample.”,
TransactionOption=TransactionOption.RequiresNew)]
public void DeleteValueByID( int ID )
{
string firstCmdString = “DELETE FROM TestTable WHERE ID=’” + ID + “‘“ ;
string secondCmdString = “DELETE FROM NonExistentTable WHERE ID=’” + ID + “‘“;
SqlCommand firstCmd = new SqlCommand(firstCmdString, sqlConnection1);
SqlCommand secondCmd = new SqlCommand(secondCmdString, sqlConnection1);
// execute first product deletion
firstCmd.Connection.Open();
firstCmd.ExecuteNonQuery();
// execute second command. When this throws an exception then the
// first command is automatically rolled back since we’re
// participating in a transaction
secondCmd.ExecuteNonQuery();
sqlConnection1.Close();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -