CSCI E-143 CertPrep:   Data   (Kalani, chapter 6)

First week:  Saturday, Nov. 6, 2004

We will take two Saturdays to cover Kalani's chapter 6,  "Consuming and Manipulating Data".   This is the most important chapter in the book,  both for use of .NET and for passing the certification test.   It is the subject with the most items you must know about which are not covered by Kalani.   And it is the longest chapter in the book (138 pages),  which is why I have split it up.

This first week we will cover everything in chapter 6 except

Be warned: that doesn't reduce the length of the chapter by much.
We will cover errors (pages 539-547).
We will not cover the additions to Kalani listed for the  second week.

The  code examples for chapter 5   (Data Binding,  remember)  are still relevant to the classes listed below.

One more thing before we start:  chapters 5 and 6 in Kalani discuss the subject of ADO.NET.   Warning:  ADO.NET is so different from "classic" ADO that it would be dangerous for you to assume that it's a simple extension.

Here are just some of the things that are in Kalani that you must know about:

Four ways of running SQL queries:

SQL Statements, their clauses, functions, and syntax

Stored Procedures   

Correspondence of Parameter Types   

The following table was cheerfully lifted from .NET's on-line help.   To find the original,  you have to do a search on "Using Parameters with a DataAdapter"—that's the name of the Help page you're looking for,  but it doesn't appear in the Help index.

Here begins the quote from .NET's on-line help:

The .NET Framework data provider type of a Parameter object is inferred from the .NET Framework type of the Value of the Parameter object,  or from the DbType of the Parameter object.   The following table shows the inferred Parameter type based on the object passed as the Parameter value or the specified DbType.  

.NET Framework type System.Data.DbType SqlDbType OleDbType OdbcType OracleType
bool Boolean Bit Boolean Bit Byte
byte Byte TinyInt UnsignedTinyInt TinyInt Byte
byte[ ] Binary VarBinary. This implicit conversion will fail if the byte array is greater than the maximum size of a VarBinary, which is 8000 bytes. For byte arrays larger than 8000 bytes, explicitly set the SqlDbType. VarBinary Binary Raw
char     Inferring a SqlDbType from char is not supported. Char Char Byte
DateTime DateTime DateTime DBTimeStamp DateTime DateTime
Decimal Decimal Decimal Decimal Numeric Number
double Double Float Double Double Double
float Single Real Single Real Float
Guid Guid UniqueIdentifier Guid UniqueIdentifier Raw
Int16 Int16 SmallInt SmallInt SmallInt Int16
Int32 Int32 Int Int Int Int32
Int64 Int64 BitInt BigInt BigInt Number
object Object Variant Variant Inferring an OdbcType from Object is not supported. Blob
string String NVarChar. This implicit conversion will fail if the string is greater than the maximum size of an NVarChar, which is 4000 characters. For strings greater than 4000 characters, explicitly set the SqlDbType. VarWChar NVarChar NVarChar
TimeSpan Time Inferring a SqlDbType from TimeSpan is not supported. DBTime Time DateTime
UInt16 UInt16 Inferring a SqlDbType from UInt16 is not supported. UnsignedSmallInt Int UInt16
UInt32 UInt32 Inferring a SqlDbType from UInt32 is not supported. UnsignedInt BigInt UInt32
UInt64 UInt64 Inferring a SqlDbType from UInt64 is not supported. UnsignedBigInt Numeric Number
    AnsiString VarChar VarChar VarChar VarChar
    AnsiStringFixedLength Char Char Char Char
    Currency Money Currency Inferring an OdbcType from Currency is not supported. Number
    Date Inferring a SqlType from Date is not supported. DBDate Date DateTime
    SByte Inferring a SqlType from SByte is not supported. TinyInt Inferring an OdbcType from SByte is not supported. SByte
    StringFixedLength NChar WChar NChar NChar
    Time Inferring a SqlType from Time is not supported. DBTime Time DateTime
    VarNumeric Inferring a SqlDbType from VarNumeric is not supported. VarNumeric Inferring an OdbcType from VarNumeric is not supported. Number

Here ends the quote from .NET's on-line help.

(Remember,  we do flat files, Kalani's pages 465-480, in the second week.)

The five Data Provider objects

DataSets.   One of the most important classes on the exam.   Discussed extensively the second week on this Kalani chapter.

DataView  objects are independent of both DataSets and DataTables,  although they are created "on" a DataTable.   (Kalani, page 494)

Strongly-Typed  DataSet  objects  (Kalani,  page 499)

Updating Data in the Database  (Kalani,  page 513.)   As you might expect,  it's complicated.   It's easy enough to change the data appearing in the DataGrid,  but getting it from there to the external database is another matter.  

(Remember,  we do XML, Kalani's pages 524-539, in the second week.)

Handling Data Errors.

Transactions.   These are SQL transactions,  which combine several SQL actions into one,  so that if one action fails,  you can recover to a known place or condition of data.   Transactions are covered only in the exercises at the end of the chapter,  on page 553.  

Miscellaneous details

Stuff we didn't get to last year


In plain language, you should know a whole lot about DataSets.   That may be the best single piece of small-scale advice I can give you about this test:  know a lot about DataSets.   (Unless, of course, your test turns out to be really different from mine.   Mr. Holley's ASP test—exam 70-315—seems,  in his memory,  to have been almost all picky SQL questions.   And SQL is no more relevant to ASP than to Windows.)

I cannot emphasize too much the importance of your mastery of this chapter's subject.   It supplies more exam questions than any other subject—in fact,  the first dozen or so questions on the exam all seemed to me to be Awful Examples of these issues.   If you're not confident of your knowledge of this stuff,  you are going to have a dreadful experience on the test.

See you Saturday.


In long Kalani,  the questions at the end of chapter 6 relevant to this week's material—everything except flat files and XML—are 1-4,  7-13,  16.

The questions relevant to week one from the questions at the end of this chapter in short Kalani are 1-5,  7,  9.

The questions relevant to week one from the two tests at the end of short Kalani are

    Test 1:  questions  3  (page 351;  answer:  page 389),  7,  8,  9,  18.

    Test 2:  questions  36  (page 422;  answer:  page 445),  38,  40,  41,  43,  45,  50.

(Some of these questions may duplicate those in long Kalani.   Both texts are listed here.)


Last revised Nov. 17, 2004