Name: ______Class: ______Date: ______ID: A

Chapter 8 Test Bank

True/False Indicate whether the statement is true or false.

____ 1. One of ASP.NET’s greatest strengths is its ability to access and manipulate .

____ 2. In today’s ever-evolving technology environment, it is often necessary for an application to access multiple databases created in different management systems.

____ 3. ASP.NET includes minimal support for ODBC.

____ 4. By eliminating the ODBC layer, your ASP.NET programs will be faster.

____ 5. ASP.NET code that directly accesses a database is more difficult to write than code that goes through ODBC.

____ 6. To connect to a SQL Server database, you instantiate an object of the SqlConnection class.

____ 7. One SqlConnection object you should use whenever you open a database connection with the Open() method is the Disconnect()method to disconnect the database connection.

____ 8. If you do not close a database connection, it remains open until you open another database.

____ 9. You must first select a database with the USE database statement before you can use it.

____ 10. It is good practice to make sure your program has connected to a database successfully before it attempts to read, write, add, or modify records.

____ 11. Instead of using an if...else block and the State property to determine whether a database connection was successful, you can also execute the Open() method within a try...catch block.

____ 12. You use the ExeReader() method of the SqlCommand class to create a SqlDataReader object, which you must assign to a variable.

____ 13. When a SqlDataReader object is first created, the cursor is initially placed after the first row in the recordset.

____ 14. The first time you use the Read() method, it places the cursor in the first row of the recordset.

____ 15. When you work with recordsets and the Read() method, you can always be certain that there is another record following the current position of the cursor.

____ 16. To determine if a next record is available, you can use the Read() method, which returns a value of true if it finds a next row in the recordset.

____ 17. You cannot execute any other commands against the database until the SqlDataReader object is closed.

1 Name: ______ID: A

____ 18. Closing a SqlDataReader object with the Finished() method allows you to reuse the SqlDataReader object to retrieve other recordsets.

____ 19. A SqlDataReader object has exclusive access to the database SqlConnection object.

____ 20. The ExecuteNonQuery() method is a method of the SqlCommand class and executes commands against a database.

____ 21. You normally use ASP.NET to create databases and tables programmatically.

____ 22. By default, the value of the first row in a field that is created with the IDENTITY keyword is assigned a value of 1 and the value for each subsequently added row is incremented by 1 from the preceding row.

____ 23. When you add records to a table that includes an IDENTITY field, you do not include a field value for the IDENTITY field.

____ 24. The values you enter in the VALUES list can be in any order.

____ 25. You must specify EMPTY in any fields for which you do not have a value.

Multiple Choice Identify the choice that best completes the statement or answers the question.

____ 26. ____ allows ODBC-compliant applications to access any data source for which there is an ODBC driver. a. Open Data Connectivity c. Open Database Connectivity b. Open Database Client d. Open Data Client

____ 27. ODBC uses ____ commands to allow an ODBC-compliant application to access a database. a. SQLDB c. DBSQL b. OSQL d. SQL

____ 28. ____ is a database connectivity technology that allows ASP and other Web development tools to access ODBC- and OLE DB-compliant databases. a. ActiveX Data Objects c. ActiveX Data Integration b. COM Data Objects d. ActiveX Data Provisioning

____ 29. ____ is a data source connectivity standard promoted by Microsoft as a successor to ODBC. a. COMDB c. OLE DB b. ActiveDB d. OpenDB

____ 30. The components that make up the Universal technology are called the ____. a. Microsoft Data Components c. Microsoft Database Components b. Microsoft Data Access Components d. Microsoft Data Activity Connection

2 Name: ______ID: A

____ 31. The first step in working with a SQL Server database in ASP.NET is to create an object of the SqlConnection class using the following syntax: ____. a. Object $SqlConnection = new SqlConnection("connection string"); b. SqlConnection object("connection string"); c. SqlConnection object.new("connection string"); d. SqlConnection object = new SqlConnection("connection string");

____ 32. Once you create an instance of the SqlConnection object, you must use the ____ method to open the specified SQL Server database instance. a. Read() c. Open() b. Start() d. Pull()

____ 33. You can select or change a database with the ____ method of the SqlConnection class. a. ChangeDatabase() c. MarkDatabase() b. Database() d. SwitchDatabase() ____ 34. The ____ object contains various properties and methods for reading the returned data. a. SqlDataWriter c. SqlDataConsumer b. SqlDataProducer d. SqlDataReader

____ 35. When you work with a SqlDataReader object, your position within the recordset is called the ____. a. cursor c. data control b. pointer d. data index

____ 36. The field names in a database table are assigned as variables in a ____ object collection. a. DataReader c. DataProvider b. SqlDataReader d. SqlReader

____ 37. If you instantiate a SqlDataReader object named empRecords for the Employees database, you can refer to the first_name field by using a statement similar to ____. a. empRecords.first_name; b. empRecords(“first_name”); c. empRecords[“first_name”]; d. empRecords.access(“first_name”);

____ 38. Whenever you use the ____ method, the content of each variable in a SqlDataReader object changes to reflect the contents of the record at the current location of the cursor. a. Fetch() c. Pull() b. Read() d. Ingest()

____ 39. When you are through working with a SqlDataReader object, you must close it with the ____ method. a. Close() c. Open() b. Flush() d. Quit()

____ 40. To close an object named empRecords, use the following the statement: ____. a. Close(empRecords); c. empRecords.Close(); b. Close(“empRecords”); d. empRecords.access(“close”);

3 Name: ______ID: A

____ 41. You use the ____ statement with the ExecuteNonQuery() method to create a new database. a. CREATE TABLE c. CREATE DATA b. CREATE INDEX d. CREATE DATABASE

____ 42. To create a table, you use the ____ statement with the ExecuteNonQuery() method. a. CREATE DATABASE c. CREATE DATA b. CREATE TABLE d. CREATE INDEX ____ 43. To identify a field as a primary key, you include the ____ keywords when you first define a field with the CREATE TABLE statement. a. PRIMARY KEY c. PRIME KEY b. INDEX KEY d. FOCAL KEY ____ 44. The ____ keyword is used with a primary key to generate a unique ID for each new row in a table. a. INDEX c. MAIN INDEX b. PRIMARY d. IDENTITY ____ 45. You can specify the starting number and the amount each subsequent row is incremented with the syntax ____. a. IDENTITY[start, increment] b. IDENTITY(start,increment) c. IDENTITY.start(increment) d. IDENTITY.increment(start)

____ 46. To delete a table, you use the ____ statement with the ExecuteNonQuery() function. a. DELETE TABLE c. DROP TABLE b. DELETE STRUCT TABLE d. CLEAR TABLE

____ 47. To add records to a table, you use the INSERT and ____ keywords with the ExecuteNonQuery() method. a. VALUES c. WITH b. DATA d. HAVING

____ 48. To add multiple records to a database, you use the BULK INSERT statement and the ____ function with a local text file containing the records you want to add. a. ExecuteNoReturn() c. ExecuteNoData() b. ExecuteVoid() d. ExecuteNonQuery() ____ 49. The ____ keyword specifies the value to assign to the fields in the records that match the condition in the WHERE keyword. a. ENTER c. FIX b. SET d. HAS

____ 50. To delete records in a table, you use the DELETE and ____ keywords with the ExecuteNonQuery() function. a. WHEN c. WHERE b. WITH d. SUCH

4 ID: A

Chapter 8 Test Bank Answer Section

TRUE/FALSE

1. ANS: T PTS: 1 REF: 406 2. ANS: T PTS: 1 REF: 406 3. ANS: F PTS: 1 REF: 406 4. ANS: T PTS: 1 REF: 407 5. ANS: F PTS: 1 REF: 407 6. ANS: T PTS: 1 REF: 408 7. ANS: F PTS: 1 REF: 410 8. ANS: F PTS: 1 REF: 410 9. ANS: T PTS: 1 REF: 411 10. ANS: T PTS: 1 REF: 412 11. ANS: T PTS: 1 REF: 414 12. ANS: F PTS: 1 REF: 417 13. ANS: F PTS: 1 REF: 418 14. ANS: T PTS: 1 REF: 418 15. ANS: F PTS: 1 REF: 418 16. ANS: T PTS: 1 REF: 418 17. ANS: T PTS: 1 REF: 419 18. ANS: F PTS: 1 REF: 419 19. ANS: T PTS: 1 REF: 419 20. ANS: T PTS: 1 REF: 421 21. ANS: F PTS: 1 REF: 424 22. ANS: T PTS: 1 REF: 433 23. ANS: T PTS: 1 REF: 433 24. ANS: F PTS: 1 REF: 435 25. ANS: F PTS: 1 REF: 436

MULTIPLE CHOICE

26. ANS: C PTS: 1 REF: 406 27. ANS: D PTS: 1 REF: 406 28. ANS: A PTS: 1 REF: 407 29. ANS: C PTS: 1 REF: 407 30. ANS: B PTS: 1 REF: 407 31. ANS: D PTS: 1 REF: 409 32. ANS: C PTS: 1 REF: 410 33. ANS: A PTS: 1 REF: 411 34. ANS: D PTS: 1 REF: 417 35. ANS: A PTS: 1 REF: 417-418 36. ANS: B PTS: 1 REF: 419 37. ANS: C PTS: 1 REF: 419

1 ID: A

38. ANS: B PTS: 1 REF: 419 39. ANS: A PTS: 1 REF: 419 40. ANS: C PTS: 1 REF: 419 41. ANS: D PTS: 1 REF: 425 42. ANS: B PTS: 1 REF: 431 43. ANS: A PTS: 1 REF: 433 44. ANS: D PTS: 1 REF: 433 45. ANS: B PTS: 1 REF: 433 46. ANS: C PTS: 1 REF: 435 47. ANS: A PTS: 1 REF: 435 48. ANS: D PTS: 1 REF: 436 49. ANS: B PTS: 1 REF: 436 50. ANS: C PTS: 1 REF: 436

2 Chapter 8 Test Bank [Answer Strip] ID: A

_____F 18. _____D 31. _____D 41.

_____T 19. _____B 42. _____T 20. _____T 1.

_____T 2. _____A 43. _____F 21. _____C 32.

_____T 22. _____F 3. _____D 44. _____T 4. _____T 23. _____A 33. _____F 5. _____B 45. _____F 24. _____T 6. _____D 34. _____F 25. _____F 7.

_____A 35. _____F 8. _____C 46. _____C 26. _____T 9. _____B 36.

_____T 10. _____A 47. _____D 27. _____C 37. _____T 11.

_____A 28. _____D 48. _____F 12.

_____F 13. _____B 38. _____C 29. _____B 49.

_____T 14. _____B 30. _____A 39. _____F 15. _____C 50.

_____T 16. _____C 40.

_____T 17.