.net barcode reader camera INTRODUCTION TO DATABASE TESTING in Font

Creation PDF-417 2d barcode in Font INTRODUCTION TO DATABASE TESTING

CHAPTER 8 INTRODUCTION TO DATABASE TESTING
PDF417 Maker In None
Using Barcode creator for Font Control to generate, create PDF-417 2d barcode image in Font applications.
www.OnBarcode.com
PDF-417 2d Barcode Generation In None
Using Barcode creation for Font Control to generate, create PDF417 image in Font applications.
www.OnBarcode.com
SqlConnection cn = new SqlConnection ("Data Source=localhost;Database=Northwind;Trusted_Connection=Yes"); Int16 intRet; SqlCommand cmd = new SqlCommand("Select count(*) from customers", cn); const int EXPECTED = 91; cn.Open(); intRet = Convert.ToInt16 (cmd.ExecuteScalar()); if (intRet == EXPECTED) { MessageBox.Show("Test passed; Expected: " + EXPECTED + " Actual: " + intRet); } else { MessageBox.Show("Test failed; Expected: " + EXPECTED + " Actual: " + intRet); } cn.Close(); The code in Listing 8-4 is pretty simple, yet effective. It calls the ExecuteScalar() method of the Command object. The ExecuteScalar() method returns an integer value that is the result of the SQL statement executed. In this case, the SQL statement is one that returns the number of rows in the Customers table. This value is compared to an expected value that is loaded into a constant called EXPECTED. If the two values are the same, then the program indicates a pass result; otherwise, it returns a failure. Keep in mind that you could use the logging techniques learned in 3 to also log this result to a file or a database. We re keeping it simple here for demonstration purposes. Another upgrade for this code would be to read the expected value from a textbox rather than use a constant this would make the code more flexible. Now you re ready to try out another example of working with ADO.NET. Exercise 8-3 will help cement your knowledge of ADO.NET for test situations. There will be many times, if you do a significant amount of work with the database, that you will find yourself using both the Database Explorer window and ADO.NET code in conjunction with each other. In Exercise 8-3, you will practice doing both.
QR Encoder In None
Using Barcode creation for Font Control to generate, create QR Code image in Font applications.
www.OnBarcode.com
Code 3/9 Encoder In None
Using Barcode generation for Font Control to generate, create Code 39 Full ASCII image in Font applications.
www.OnBarcode.com
Exercise 8-3: Querying a Database Using ADO.NET
Encoding GTIN - 128 In None
Using Barcode drawer for Font Control to generate, create UCC-128 image in Font applications.
www.OnBarcode.com
Barcode Generation In None
Using Barcode encoder for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
The purpose of Exercise 8-3 is to increase your familiarity with ADO.NET programming and the use of the Database Explorer. You will write ADO.NET code to accomplish a simple test to verify the existence and amount of test data added into your database. You will also modify the data in the database directly by adding some test data using the database and then rerunning your ADO.NET code to verify the new data entered correctly. 1. Start a new Visual Studio Windows Forms project and name it MaxOrdersTest. 2. Add one button and a listbox control to the form. In the Properties window, change the following properties of these two new buttons and the listbox according to Table 8-4. You can arrange and size these controls any way you like but be sure to enlarge the listbox so that it s relatively large and wide.
Painting UPC - 13 In None
Using Barcode generator for Font Control to generate, create GTIN - 13 image in Font applications.
www.OnBarcode.com
ISSN - 10 Creator In None
Using Barcode generator for Font Control to generate, create ISSN - 10 image in Font applications.
www.OnBarcode.com
CHAPTER 8 INTRODUCTION TO DATABASE TESTING
PDF 417 Scanner In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Scan PDF417 In VS .NET
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Table 8-4. Controls and Associated Properties for Exercise 8-3
Encode Code 128 Code Set A In Java
Using Barcode generator for Android Control to generate, create Code 128 image in Android applications.
www.OnBarcode.com
Barcode Generation In VS .NET
Using Barcode drawer for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
Control
Paint PDF 417 In Java
Using Barcode printer for BIRT reports Control to generate, create PDF-417 2d barcode image in Eclipse BIRT applications.
www.OnBarcode.com
Creating Barcode In Objective-C
Using Barcode creation for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
listBox1 Button1
PDF-417 2d Barcode Decoder In C#
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Creating Barcode In None
Using Barcode generator for Office Excel Control to generate, create Barcode image in Office Excel applications.
www.OnBarcode.com
Name Property
Scanning USS Code 128 In .NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
UPC-A Printer In None
Using Barcode generation for Microsoft Excel Control to generate, create UPCA image in Excel applications.
www.OnBarcode.com
lstResults cmdADO
Code 39 Full ASCII Encoder In None
Using Barcode printer for Online Control to generate, create Code 39 Extended image in Online applications.
www.OnBarcode.com
QR Creation In Java
Using Barcode printer for Java Control to generate, create Quick Response Code image in Java applications.
www.OnBarcode.com
Text Property
Start test
Caution The listbox name starts with the letter l, not the number 1!
3. Open the code window for the form. On the top of the code window, you will need to add the following statements (in their usual locations): VB .NET Imports System.Data.OleDb C# using System.Data.OleDb; 4. Now you will need to move the Microsoft Access database into the correct location. 8 s exercise folder contains a copy of the Northwind.mdb database. Locate this file, then copy and paste it into the bin directory of your project. You can accomplish this several ways, including just copying and pasting the file using Windows Explorer. However, the easiest way to accomplish this is to click Show All Files in the Solution Explorer window, then locate the bin folder and the Debug folder within it. Right-click the Debug folder and choose Add Existing Item. Navigate to the exercise folder for 8 and select the Northwind.mdb database. This will add the database to your project. (You will possibly have a Wizard dialog display. You can simply dismiss this dialog by clicking Cancel.) 5. Next, you will add ADO code to the Click event of the cmdADO button to open a connection to the Microsoft Access Northwind sample database. You will then add code to execute a SQL statement that will return the most recently ordered items from the Orders table into the Listbox control (see the SQL Statements for Testing section earlier in this chapter), as well as add code to report the number of records found into a message box. Type the code in Listing 8-5 into to the cmdADO_Click event. Listing 8-5. Code to Add to the cmdADO_Click Event VB .NET Dim cn As New OleDbConnection _ ("Provider=Microsoft.jet.oledb.4.0;Data Source=Northwind.mdb") Dim dr As OleDbDataReader Dim intCount As Int16 = 0 cn.Open() Dim cmd As New OleDbCommand
Copyright © OnBarcode.com . All rights reserved.