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

Saturday, Oct. 30, 2004

The largest single topic in Kalani and on the exam is that of access to data.   We will begin this week with a simple introduction to the topic,  before we can go on to this week's specific interest.   (I have put some simple code to read database tables  here.)  

This Saturday we will cover Kalani's chapter 5, "Data Binding".   I think this is an interesting chapter,  both for the subject itself and for the surprising lack of coverage elsewhere.   This chapter in Kalani was the first time I had heard about Data Binding at all.

Data binding in .NET is the establishment of links between data as displayed to the user and data as held in the machine's internal memory.   It is not  linkage between either of these and data held externally,  say,  in a file or relational database.   (Data Binding in .NET is therefore utterly different from Data Binding in Java.)  

You will find that it also has some tricky lines of code,  such as the combination of simple and complex data binding shown by example 5.6,  on pages 367-369.   The text itself says (page 369):  "Understanding Step by Step 5.6 is crucial for the effective use of ComboBox and ListBox controls in applications.   Using these controls can be a little tricky [!] because the ListBox control is bound to two different things."   Kalani then goes on to try to explain it.   Well, good luck.

Here is a summary of the chapter:


What Kalani leaves out of his database examples

He omits  try  and  catch.   (But he says so in the box on page 439,  adding,  about error-handling:  "You must use it in real-life programs.")   It is in fact fatally easy to fall into this error.   You want to see a really annoyed TA?   Try leaving  try  and  catch out of your code,  and having the TA discover that your code won't run on his or her machine.  

You will find error-handling code to use while reading databases  here.  

Simple Data Binding

Complex Data Binding

Combining Simple and Complex Data Binding

Data Wizards

Pages 385-391 in Kalani show how to use Wizards to generate DataGrids that display relational data.   You should try a couple of these,  and you should look at the generated code,  especially at the declarations of things like  DataSource  and  DataMember  for the related tables as displayed in the DataGrids.   This also applies to exercise 5.4 on page 414,  where Kalani creates two DataGrids in a parent-child relationship,  while writing only a single word of code.  

The Server Explorer

This is the pane which competes with the ToolBox in the upper left corner of the screen.

Filtering and Transforming Data

There are obviously two ways to doing this.   Choosing between these methods is a serious question in the design of your database and programs.   Ask our Mr. Holley about the 70-229 exam he's studying for.   It's on SQL Server Database Design.


The questions at the end of this chapter will be sufficient warning for what might be on a test.   I think there will only be a question or two on a real test on this subject,  but it is very satisfying to feel you know the answer.

See you Saturday.


You will find that the sample exam questions for this chapter in  "long Kalani"  seem longer and more complicated than those in earlier chapters.   This makes them more representative of the real test.  

This chapter's questions in long Kalani vary in quality.   The questions are generally good,  except for these:

Here are the relevant questions from the two tests at the end of the "short Kalani"  book:  

    Test 1:  questions  1  (page 350;  answer:  page 388),  2,  14,  15,  16.

    Test 2:  questions  3  (page 403;  answer:  page 439),  12.

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


Last revised Oct. 29, 2004