- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
THE BASICS OF STORING TEST DATA in Font
THE BASICS OF STORING TEST DATA Draw PDF-417 2d Barcode In None Using Barcode encoder for Font Control to generate, create PDF-417 2d barcode image in Font applications. www.OnBarcode.comDraw PDF 417 In None Using Barcode drawer for Font Control to generate, create PDF417 image in Font applications. www.OnBarcode.com Note To try the examples in this section, you will need to have Microsoft Access installed.
Encode Quick Response Code In None Using Barcode maker for Font Control to generate, create Quick Response Code image in Font applications. www.OnBarcode.comCode 128B Creation In None Using Barcode creator for Font Control to generate, create Code 128 Code Set C image in Font applications. www.OnBarcode.comListing 3-10. Writing Test Results to a Microsoft Access Database VB .NET 'Make sure to add Imports System.Data.OleDb at the top of the code page Dim cn As New OleDbConnection _ ("Provider=Microsoft.jet.oledb.4.0;Data Source=TestResultsDB.mdb") Dim iRet As Integer cn.Open() Dim cmd As New OleDbCommand( _ "Insert into TestResults (TestID, TestDate, Reqmt, Tester, Result) " & _ "Values (3, '01-Jan-2006', 'Test Reqmt ABC', 'M. Sweeney', 1)", cn) iRet = cmd.ExecuteNonQuery cn.Close() C# //Make sure to add using System.Data.OleDb at the top of the code page OleDbConnection cn = new OleDbConnection( "Provider=Microsoft.jet.oledb.4.0;Data Source=TestResultsDB.mdb"); int iRet; cn.Open(); OleDbCommand cmd = new OleDbCommand( "Insert into TestResults (TestID, TestDate, Reqmt, Tester, Result) " + "Values (3, '01-Jan-2006', 'Test Reqmt ABC', 'M. Sweeney', 1)", cn); iRet = cmd.ExecuteNonQuery(); cn.Close(); Let s examine this code. The first line imports or uses the System.Data.OleDb namespace. This OleDb namespace contains code for ODBC database access, and the System.Data.SQLClient namespace contains resources for accessing Microsoft s SQL Server database. Since you want to use Microsoft Access, you must use the general library, which is located in the System.Data.OleDb namespace. The next line creates a Connection object and points it to the TestResultsDB.mdb database. (The TestResultsDB database is a sample Access database that we ve created for this book and have included in the code for this chapter. You will use it in Exercise 3-3.) In this example, the database resides in the bin folder of the application; otherwise, you could need a full pathname to the database location. After the integer variable declaration, the following command actually opens the connection: cn.Open(); Encoding UCC - 12 In None Using Barcode maker for Font Control to generate, create UPC-A Supplement 5 image in Font applications. www.OnBarcode.comDataMatrix Encoder In None Using Barcode creation for Font Control to generate, create Data Matrix image in Font applications. www.OnBarcode.comCHAPTER 3 THE BASICS OF STORING TEST DATA
Barcode Drawer In None Using Barcode creation for Font Control to generate, create Barcode image in Font applications. www.OnBarcode.comPlanet Maker In None Using Barcode printer for Font Control to generate, create Planet image in Font applications. www.OnBarcode.comOnce the database is opened successfully, the next few lines of Listing 3-10, repeated here, comprise a single statement that will create a Command object and set it up so that when the Command object is executed, it will send a SQL Insert statement to the TestResults table within the database: VB .NET Dim cmd As New OleDbCommand( _ "Insert into TestResults (TestID, TestDate, Reqmt, Tester, Result) " & _ "Values (3, '01-Jan-2006', 'Test Reqmt ABC', 'M. Sweeney', 1)", cn) C# OleDbCommand cmd = new OleDbCommand( "Insert into TestResults (TestID, TestDate, Reqmt, Tester, Result) " + "Values (3, '01-Jan-2006', 'Test Reqmt ABC', 'M. Sweeney', 1)", cn); Finally, in the last line of Listing 3-10, repeated here, the ExecuteNonQuery() method of the Command object is called to actually execute the command against the database: VB .NET iRet = cmd.ExecuteNonQuery C# iRet = cmd.ExecuteNonQuery; Now that you know the basics of creating and using the Connection and Command objects, you re ready to start exploring how to incorporate database access into your automated tests. PDF 417 Generator In None Using Barcode printer for Microsoft Excel Control to generate, create PDF417 image in Excel applications. www.OnBarcode.comPDF417 Encoder In Visual Basic .NET Using Barcode generator for VS .NET Control to generate, create PDF417 image in .NET applications. www.OnBarcode.comReporting Test Results to a Database
Draw DataMatrix In Java Using Barcode generator for BIRT Control to generate, create Data Matrix 2d barcode image in BIRT applications. www.OnBarcode.comPaint PDF-417 2d Barcode In Java Using Barcode generation for Java Control to generate, create PDF417 image in Java applications. www.OnBarcode.comThe SQL Insert statement used in Listing 3-10 inserts into a specially created table called TestResults. The TestResults table in the TestResultsDB database has a number of fields useful for reporting test information. You can modify this table within Microsoft Access, to add or remove columns, as desired (note that you will need to have Microsoft Access installed to make changes). Table 3-2 lists the fields in the TestResults table with explanations for their intended use. Universal Product Code Version A Scanner In .NET Framework Using Barcode scanner for .NET framework Control to read, scan read, scan image in .NET applications. www.OnBarcode.comCode 3/9 Recognizer In None Using Barcode reader for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.comTable 3-2. Fields in the TestResults Table (TestResultsDB Sample Database) Generating PDF417 In None Using Barcode encoder for Word Control to generate, create PDF 417 image in Word applications. www.OnBarcode.comBarcode Recognizer In Java Using Barcode decoder for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comField
Paint UCC - 12 In Java Using Barcode drawer for BIRT Control to generate, create UCC - 12 image in BIRT applications. www.OnBarcode.comCode 3/9 Generator In Java Using Barcode creation for Java Control to generate, create Code 39 Full ASCII image in Java applications. www.OnBarcode.comTestID TestDate Reqmt Tester
Create PDF-417 2d Barcode In Visual Basic .NET Using Barcode generation for .NET framework Control to generate, create PDF-417 2d barcode image in .NET applications. www.OnBarcode.comUCC-128 Drawer In Java Using Barcode drawer for Java Control to generate, create EAN / UCC - 13 image in Java applications. www.OnBarcode.comData Type
Integer Date Text Text
Explanation
A unique number so that every test result can be identified individually. Date this entry is added. Requirements identifier so this test result can be traced back to test requirements. Name of the tester running the test that entered this record. THE BASICS OF STORING TEST DATA
Table 3-2. Fields in the TestResults Table (TestResultsDB Sample Database) (Continued) Field
TestNumber BuildNumber Result Comments
Data Type
Integer Integer Boolean Text
Explanation
This number represents the test run. Many test IDs could be linked to one TestNumber. This number represents the particular build of the software release. Pass or Fail of this test. 0 will be stored if the test fails and 1 if the test passes. Any additional comments desired for this particular test result. Notice that in the code in Listing 3-10, our Insert statement inserts into only five columns of the table: TestID, TestDate, Reqmt, Tester, and Result. It may not be necessary to use every column every time, but you should be consistent across all tests. Note The code in Listing 3-10 is contained in the 3 Exercise folder. This demo application is called
|
|