MIS 120 STUDY GUIDE FOR EXAM 2
NOTE: At least 35 the following questions will be in EXAM 2
Chapter 13: An introduction to database programming
1. The hardware components of a typical multi-user system are
|a. |the data access API, the SQL queries, and the DBMS |
|b. |PCs, Macintoshes, and workstations |
|c. |the clients, the server, and the network |
|d. |the monitor, the hard drive, and the printer |
ANS: C
2. A system that divides the processing between the clients and the server is called
|a. |a server-based system |c. |a client/server system |
|b. |an enterprise system |d. |a mainframe system |
ANS: C
3. To communicate with a DBMS, the application software sends
|a. |command objects |c. |SQL queries |
|b. |dataset requests |d. |primary keys |
ANS: C
4. To store the databases of a client/server system, the server requires
|a. |a database management system |c. |a data access API |
|b. |an SQL query |
ANS: A
5. What does a relational database use to uniquely identify each row in a table?
|a. |indexes |c. |non-primary keys |
|b. |foreign keys |d. |primary keys |
ANS: D
6. What does a relational database use to relate tables in the database to each other?
|a. |indexes |c. |non-primary keys |
|b. |foreign keys |d. |primary keys |
ANS: B
7. If a row in one table is related to one or more rows in another table, the tables are said to have a
|a. |one-to-many relationship |c. |many-to-many relationship |
|b. |one-to-one relationship |
ANS: A
8. The data that’s retrieved by a Select statement is called a
|a. |dataset |c. |data reader |
|b. |SQL query |d. |result set |
ANS: D
9. A join that returns records from related tables only if their related fields match is called
|a. |an outer join |c. |a cross join |
|b. |an inner join |d. |a data join |
ANS: B
10. Which of the following can a Select statement not do?
|a. |Retrieve data |c. |Combine data from two tables |
|b. |Create calculated fields |d. |Modify selected data |
ANS: D
11. The result set retrieved by the following Select statement contains records that have
Select Balance, Number
From Accounts
Where Balance < 0
|a. |all of the columns from the Accounts table |
|b. |two of the columns from the Account table |
|c. |all of the columns from the Accounts table where Balance is less than 0 |
|d. |two of the columns from the Accounts table where Balance is less than 0 |
ANS: D
Code example 13-1
Select VendorName, InvoiceNumber, InvoiceDate, InvoiceTotal
From Vendors Inner Join Invoices
On Vendors.VendorID = Invoices.VendorID
Where InvoiceTotal >= 500
Order By VendorName Desc
12. (Refer to code example 13-1.) If VendorName contains string data and InvoiceTotal contains decimal values, how will the result set be ordered?
|a. |alphabetically starting with A |c. |numerically starting with 0 |
|b. |alphabetically starting with Z |d. |numerically starting with 500 |
ANS: B
13. (Refer to code example 13-1.) How many columns will the result set have?
|a. |4 |c. |6 |
|b. |5 |d. |7 |
ANS: A
14. (Refer to code example 13-1.) What table(s) does the data in the result set come from?
|a. |Vendors |c. |Vendors and Invoices |
|b. |Invoices |
ANS: C
15. What does the following SQL statement add to the Terms table?
Insert Into Terms (TermsDueDays)
Values (90)
|a. |A row with a value of 90 for the TermsDueDays column |
|b. |90 rows with a column of TermsDueDays |
|c. |All rows where the TermsDueDays column has a value of 90 |
|d. |A TermsDueDays column with a default value of 90 |
ANS: A
16. When you use the .NET data provider objects to retrieve data from a database, you can store the data in an object called a
|a. |business class |c. |dataset |
|b. |database |d. |connection |
ANS: C
17. What object does use to store a SQL statement?
|a. |data reader |c. |command |
|b. |data adapter |d. |connection |
ANS: C
18. What type of concurrency does use by default to check whether a row has changed before an update or delete operation is performed?
|a. |optimistic |c. |last in wins |
|b. |pessimistic |d. |first in wins |
ANS: A
19. What is the primary function of a data adapter?
|a. |To define the connection to a database |
|b. |To manage the flow of data between a client program and a database |
|c. |To convert data to the format required by an application |
|d. |To define a SQL operation to be performed |
ANS: B
20. Which of the folowing statements is not true? An dataset object
|a. |has a structure similar to a relational database |
|b. |can contain one or more tables |
|c. |can define relationships between tables |
|d. |can store command objects |
ANS: D
21. Concurrency occurs when
|a. |an update or delete operation is refused |
|b. |two or more users retrieve and then try to update data in the same row of a table at the same time |
|c. |an update or delete operation is resubmitted to the database |
|d. |a program checks if a row has changed before updating or deleting it |
ANS: B
22. ’s disconnected data architecture
|a. |eliminates the need for concurrency control |
|b. |requires additional system resources |
|c. |allows the database connection to be closed after each operation |
|d. |requires that programs be designed to retrieve and update a single row at a time |
ANS: C
23. If you execute a Select statement directly instead of using a data adapter, what object do you use to read the data that’s returned?
|a. |dataset |
|b. |result set |
|c. |data reader |
|d. |data table |
ANS: C
24. Which of the following is not true about a table adapter?
|a. |It can only be generated by the designer |
|b. |It can contain a single query |
|c. |It has a built-in connection object |
|d. |It is similar to a data adapter |
ANS: B
Chapter 14: How to use data sources with databases (part 1)
1. When you use a data source to get data from a database, you can
|a. |select just one table with all of its columns |
|b. |select one or more tables with all of its columns |
|c. |select just one table and just the columns that you want |
|d. |select one or more tables with just the columns that you want from each table |
ANS: D
2. If you save the connection string for a data source in the configuration file for the application,
|a. |the string is automatically adjusted if you change it in your Visual Basic code |
|b. |you won’t have to change the string if the connection changes |
|c. |you can change the string in just the configuration file if the connection changes |
|d. |you can change the string in just one form if the connection changes |
ANS: C
3. When you drag a data source onto a form, it adds a DataGridView control to the form and it adds all but one of the objects that follow to the Component Designer tray. Which object is it?
|a. |BindingSource object |c. |DataSet object |
|b. |DataAdapter object |d. |TableAdapter object |
ANS: B
4. The BindingNavigator control (toolbar) that’s added to a form along with a DataGridView control can be used to do all but one of the following. Which one is it?
|a. |navigate through the rows |c. |undo an update |
|b. |delete a row |d. |add a row |
ANS: C
5. When you edit the properties or columns of a DataGridView control, you can do all but one of the following. Which one is it?
|a. |disable row navigation |c. |reorder the columns |
|b. |change column headers |d. |disable row additions |
ANS: A
6. The Fill method of a table adapter object that’s working with a SQL Server database will throw errors of the
|a. |SqlException class |c. |DataException class |
|b. |OdbcException class |d. |ConstraintException class |
ANS: A
7. A NoNullAllowedException is thrown when the Update method of a table adapter object tries to update the database with a record that has
|a. |null values in all of its columns |
|b. |a null value in a single column |
|c. |a null value in a column that doesn’t allow nulls |
|d. |a null value for the primary key of a record |
ANS: C
8. When a DBConcurrencyException is caught, your code should normally display a message to the user that indicates that some rows weren’t updated and then
|a. |return to the form so the user can retry the updates |
|b. |use the properties of the exception object to fix the rows that weren’t updated |
|c. |use the Update method to try to update those rows again |
|d. |use the Fill method to retrieve the current data from the database |
ANS: D
9. When a DataGridView control throws a data error event, the event handler should normally
|a. |display a message that gives the row and column of the field that caused the error |
|b. |disable the Update method so the row won’t be updated |
|c. |refresh the DataGridView control so the user can re-enter the data for the current row |
|d. |set the Cancel property of the EventArgs to true |
ANS: A
10. The easiest way to test for concurrency errors is to
|a. |run the application from two different PCs |
|b. |runs the application from two instances of Visual Studio |
|c. |start the application twice from one instance of Visual Studio |
ANS: B
11. When you use a data source with individual controls instead of a DataGridView control, you can do all but one of the following. Which one is it?
|a. |use text boxes to display the values in the fields of each record in a table |
|b. |use a toolbar to navigate from one record to another |
|c. |format the data that’s retrieved from the database before it’s displayed |
|d. |code exception handlers for DataError events |
ANS: D
12. When you bind a combo box to a table in one data source, you can display the data from one column of that table in the list of the combo box and use the selected value to
|a. |update another column in that table |
|b. |update a column in a table of another data source |
|c. |update another column in that table or a column in a table of another data source |
|d. |update another column in that table and a column in a table of another data source |
ANS: C
13. When you add a parameterized query to a data table, Visual Studio automatically adds a toolbar to the form that lets you
|a. |navigate from one parameter to the next |
|b. |navigate from one parameter value to the next |
|c. |enter the parameter name and value that’s needed by the query |
|d. |enter the parameter value that’s needed by the query |
ANS: D
14. When you add a parameterized query to a data table, Visual Studio automatically generates the code that’s required for executing the query, including a try-catch statement that catches
|a. |data provider exceptions |
|b. | exceptions |
|c. |all types of data exceptions |
|d. |all types of exceptions |
ANS: D
15. When you’re using data sources, an easy way to provide the default value for a column in a table that doesn’t allow nulls is to
|a. |write a statement that adds the default value to the column |
|b. |use the DataSet Designer to set the DefaultValue property for the column |
|c. |use the Form Designer to set the DefaultValue property for the column |
|d. |let the database supply its default value for the column |
ANS: B
16. Because Visual Studio uses a disconnected data architecture when you use data sources, optimistic concurrency is implemented by
|a. |the generated Visual Basic statements |c. |the database constraints |
|b. |the generated SQL statements |d. |the database management system |
ANS: B
17. In the statement that follows, the Fill method
Me.productsTableAdapter.Fill(Me.mmaBooksDataSet.Products)
|a. |loads the Products table in the dataset with data from the database |
|b. |loads the Products table in the table adapter with data from the database |
|c. |loads the Products table in the dataset with data from the table adapter |
|d. |loads the Products table in the table adapter with data from dataset |
ANS: A
18. In the statement that follows, the Update method
Me.productsTableAdapter.Update(Me.mmaBooksDataSet.Products)
|a. |updates the Products table in the dataset with data from the database |
|b. |updates the Products table in the table adapter with data from the database |
|c. |updates the database with data from the Products table in the dataset |
|d. |updates the database with data from the Products table in the table adapter |
ANS: C
19. In the statement that follows, the FillByCustomerID method
Me.customersTableAdapter.FillByCustomerID( _
Me.mmaBooksDataSet.Customers, customerID)
|a. |loads the Customers table in the dataset with data from the database in customerID sequence |
|b. |loads the customers table adapter with data from the database |
|c. |loads the Customers table with one record from the database |
|d. |loads the customers table adapter with one record from the database |
ANS: C
20. When you use a data source, the SQL statements that are used to retrieve and update records can be found in the SelectCommand and UpdateCommand properties of the
|a. |table adapter |
|b. |binding source |
|c. |data source |
|d. |dataset |
ANS: A
Chapter 16: How to use to write your own data access code
1. Which of the following is not set in a connection string?
|a. |security type |
|b. |command type |
|c. |database name |
|d. |server name |
ANS: B
2. Given a valid connection string named conString, which of the following statements creates a connection for a SQL Server database?
|a. |conString.Open() |
|b. |Dim con As New Connection(conString) |
|c. |Dim con As New SqlConnection() |
| |con.SqlConnectionString = conString |
|d. |Dim con As New SqlConnection(conString) |
ANS: D
3. What two properties of a command object do you always need to set before you call one of the methods of the command?
|a. |Connection and CommandType |
|b. |Connection and CommandText |
|c. |CommandText and Parameters |
|d. |Command Type and CommandText |
ANS: B
4. Which of the following is not a method of a command object?
|a. |ExecuteNonQuery |
|b. |ExecuteActionQuery |
|c. |ExecuteReader |
|d. |ExecuteScalar |
ANS: B
5. How is a parameter in a parameterized query for a SQL Server data adapter identified?
|a. |by a question mark (?) |
|b. |by an asterisk (*) |
|c. |by a named variable that begins with an at sign (@) |
|d. |by a named variable that begins with a colon (:) |
ANS: C
6. Which of the following code fragments does not use a named variable?
|a. |WHERE MovieID = @MovieID |
|b. |WHERE Title = :MovieTitle |
|c. |WHERE MovieYear = ? |
|d. |WHERE Code = @MovieCode AND Title = @MovieTitle |
ANS: C
7. Which group of statements creates a SQL Server parameter object named userIDParm that sets the value of a parameter named UserID to the userID variable and sets its data type to Int32?
|a. |Dim userIDParm As New Parameter("UserID", userID) |
| |userIDParm.Type = Type.Int32 |
|b. |Dim userIDParm As New Parameter("@UserID", userID) |
| |userIDParm.DbType = DbType.Int32 |
|c. |Dim userIDParm As New SqlParameter("@UserID", userID) |
| |userIDParm.DbType = DbType.Int32 |
|d. |Dim userIDParm As New SqlParameter("@UserID", userID) |
| |userIDParm.Type = Type.Int32 |
ANS: C
8. Which of the following statements adds a parameter named userIDParm to an SQL statement that’s stored in a command object named updateCommand?
|a. |updateCommand.Add(userIDParm) |
|b. |updateCommand.Parameter(userIDParm) |
|c. |updateCommand.Parameter.Add(userIDParm) |
|d. |updateCommand.Parameters.Add(userIDParm) |
ANS: D
9. Given a valid SqlCommand object named selectCommand, which of the following statements creates a SqlDataReader object that returns a single row?
|a. |Dim employeeReader As SqlDataReader = _ |
| |selectCommand.ExecuteSqlDataReader(Single) |
|b. |Dim employeeReader As SqlDataReader = _ |
| |selectCommand.GetSqlDataReader() |
|c. |Dim employeeReader As SqlDataReader = _ |
| |selectCommand.ExecuteReader(CommandBehavior.SingleRow) |
|d. |Dim employeeReader As SqlDataReader = _ |
| |selectCommand.GetSqlDataReaderSingle() |
ANS: C
10. Given a valid SqlDataReader object named employeeReader, which of the following statements retrieves the first column of the current row and stores it in a string variable named s?
|a. |Dim s As String = employeeReader(0) |
|b. |Dim s As String = employeeReader(0).ToString |
|c. |Dim s As String = employeeReader(1) |
|d. |Dim s As String = employeeReader.GetFirstColumn() |
ANS: B
11. Given a SqlCommand object named updateCommand that contains a valid SQL Update statement, which of the following statements executes the Update statement and returns the number of rows that were affected by that statement?
|a. |Dim count As Integer = updateCommand.ExecuteNonQuery() |
|b. |Dim count As Integer = updateCommand.ExecuteActionQuery() |
|c. |Dim count As Integer = updateCommand.ExecuteScalar() |
|d. |Dim count As Integer = updateCommand.ExecuteQuery() |
ANS: A
12. Given a DataSet object named employeesDataSet, which of the following refers to the first table in that dataset?
|a. |employeesDataSet.Table("Employees") |
|b. |employeesDataSet.Tables(0) |
|c. |employeesDataSet.DataTable(0) |
|d. |employeesDataSet.DataTables(0) |
ANS: B
13. What must be defined before you call the Fill method of a data adapter?
|a. |The Select statement for the data adapter |
|b. |The Insert, Update, and Delete statements for the data adapter |
|c. |The schema information for the table where the data will be stored |
|d. |The table mappings for the data adapter |
ANS: A
14. Which of the following is not a member of the MissingSchemaAction enumeration that is used with the Fill method of a data adapter object?
|a. |Add |
|b. |AddWithKey |
|c. |Update |
|d. |Error |
ANS: C
15. Which of the following statements fills a data table named Employees in a dataset named employeesDataSet using a data adapter named employeesDataAdapter?
|a. |employeesDataSet.Fill(employeesDataAdapter, "Employees") |
|b. |employeesDataAdapter.Fill(employeesDataSet, "Employees") |
|c. |employeesDataAdapter.Fill(employeesDataSet, Employees) |
|d. |employeesDataSet.Fill(employeesDataAdapter, Employees) |
ANS: B
16. Which of the following statements is not true about a transaction?
|a. |A transaction can’t be rolled back after it has been committed. |
|b. |A transaction is a group of SQL statements that are combined into a logical processing unit. |
|c. |A transaction object is associated with one or more command objects. |
|d. |A transaction object is instantiated by using the BeginTransaction method of a command object. |
ANS: D
17. Given a transaction object named salesTran and a connection object named connection, which of the following statements makes all changes made by the transaction permanent?
|a. |mit() |c. |mit(connection) |
|b. |salesTran.EndTrans() |d. |salesTran.EndTrans(connection) |
ANS: A
18. Given a transaction object named salesTran and a command object named salesCmd, which of the following statements associates the command with the transaction?
|a. |salesTran += salesCmd |c. |salesCmd.Transaction = salesTran |
|b. |salesTran.Add(salesCmd) |d. |salesTran.Transaction = salesCmd |
ANS: C
19. You can use a SQLCommandBuilder object to generate the Insert, Update, and Delete commands
|a. |for a data adapter that uses any SELECT statement |
|b. |for a data adapter that uses a SELECT statement that has a primary key |
|c. |for a dataset that uses any SELECT statement |
|d. |for a dataset that uses a SELECT statement that doesn’t do a join |
ANS: B
20. Which of the following declarations could be used for a function in a database class that deletes an employee row in a database table and returns a true/false value if the operation was successful? Assume that this method enforces optimistic concurrency.
|a. |Public Shared Function DeleteEmployeeData(ByVal employeeID As Integer) _ |
| |As Boolean |
|b. |Public Shared Function DeleteEmployeeData(ByVal employee As Employee) _ |
| |As Boolean |
|c. |Public Shared Function DeleteEmployee(ByVal employeeID As Integer) _ |
| |As Integer |
|d. |Public Shared Function DeleteEmployee(ByVal employee As Employee) _ |
| |As Integer |
ANS: B
Chapter 17: How to use data sources with business objects
MULTIPLE CHOICE
1. The shortcoming that you encounter when you use data sources with databases is that you
|a. |can’t get the benefits of data binding |
|b. |can’t separate the presentation code from the database code |
|c. |can’t use optimistic concurrency |
|d. |can’t use data adapters |
ANS: B
2. The shortcoming that you encounter when you use code for database access without using data sources is that you
|a. |can’t get the benefits of data binding |
|b. |can’t separate the presentation code from the database code |
|c. |can’t use optimistic concurrency |
|d. |can’t use data adapters |
ANS: A
3. Which of the following statements is not true about the use of data sources with business objects?
|a. |You have to write the code for populating the business objects. |
|b. |You don’t get the benefit of data binding. |
|c. |You can develop 3-layer applications. |
|d. |You have to write the code for inserting, updating, and deleting the records in a database. |
ANS: B
4. To create an object data source, you need to do all but one of the following. Which one is it?
|a. |Write the code for the business object. |
|b. |Store the business object in a class library. |
|c. |Select the database table and columns that you’re going to use for the business object. |
|d. |Select the object that you wish to use for the object data source. |
ANS: C
5. When a DataGridView control is bound to an object data source, you can use the CurrencyManager object to synchronize the grid with the object data source
|a. |whenever rows are added to or deleted from the database |
|b. |whenever a row is updated in the database |
|c. |each time the user navigates to a new row |
|d. |each time the user navigates to a new row or a new column |
ANS: A
6. When you use transactions with object data sources, you can issue all of the SQL commands for the transaction in a try block
|a. |by themselves |
|b. |along with the commit method for the transaction |
|c. |with the commit method in the finally block |
|d. |with the commit method after the try-catch statement |
ANS: B
7. To make it easy to change the connection for all of the database classes in an application when you use object data sources, it’s best to
|a. |use the application configuration file to provide the connection string |
|b. |provide a public property in one of the database classes that holds the required connection string |
|c. |provide a public method in one of the database classes that returns the connection object |
|d. |provide a method in each database class that returns the connection object |
ANS: C
8. You can bind a combo box to an object data source during design time by using the binding source, but you need to override that binding at runtime
|a. |when you establish the connection to the database |
|b. |when you create the object that the combo box should be bound to |
|c. |when the user selects a new item from the combo box |
|d. |whenever the data in the database changes |
ANS: B
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.