Đang chuẩn bị liên kết để tải về tài liệu:
Pro .NET 2.0 Extreme Programming 2006 phần 7
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'pro .net 2.0 extreme programming 2006 phần 7', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | CHAPTER 13 FIRST ITERATION 185 Build connection string connectionstring new StringBuilder Driver Microsoft Access Driver .mdb connectionString.Append DBQ c xpnet database Northwind.mdb SetUp public void Init try OdbcConnection dataConnection new OdbcConnection dataConnection.ConnectionString connectionString.ToString dataConnection.Open OdbcCommand dataCommand new OdbcCommand dataCommand.Connection dataConnection Build command string StringBuilder commandText new StringBuilder INSERT INTO Products ProductName commandText.Append CategoryID UnitPrice commandText.Append UnitsInStock VALUES commandText.Append productName commandText.Append commandText.Append categoryID commandText.Append commandText.Append price commandText.Append commandText.Append quantity commandText.Append dataCommand.CommandText commandText.ToString int rows dataCommand.ExecuteNonQuery Make sure that the INSERT worked Assert.AreEqual 1 rows Unexpected row count gasp Get the ID of the category we just inserted This will be used to remove the category in the TearDown commandText new StringBuilder SELECT ProductID FROM commandText.Append Products WHERE ProductName commandText.Append Bogus Product 186 CHAPTER 13 FIRST ITERATION dataCommand.CommandText commandText.ToString OdbcDataReader dataReader dataCommand.ExecuteReader Make sure that we found our product if dataReader.Read productID dataReader.GetInt32 0 dataConnection.Close catch Exception e Assert.Fail Error e.Message TearDown public void Destroy try OdbcConnection dataConnection new OdbcConnection dataConnection.ConnectionString connectionString.ToString dataConnection.Open OdbcCommand dataCommand new OdbcCommand dataCommand.Connection dataConnection Build command string StringBuilder commandText new StringBuilder DELETE FROM Products WHERE ProductID commandText.Append productID dataCommand.CommandText commandText.ToString int rows dataCommand.ExecuteNonQuery Make sure that the DELETE worked Assert.AreEqual 1 rows Unexpected row count gasp .