Skip to Content
Beginning C# 3.0
book

Beginning C# 3.0

by Jack Purdum
May 2008
Beginner
550 pages
13h 22m
English
Wrox
Content preview from Beginning C# 3.0

A.12. Chapter 14

A.12.1. Exercise 1 Solution

The two commands are:

SELECT * FROM Friends WHERE status = 1

and:

SELECT SUM(status) FROM Friends

The reason the aggregate SUM function works is that we assigned the value of 1 to an active member and 0 to inactive members. Therefore, SUM also produces a count of active members.

A.12.2. Exercise 2 Solution

The SELECT statement might be written as:

SELECT * FROM Friend WHERE status = 1 AND ADDR2 <> '' AND State = 'IN'

Note that the middle expression of the WHERE predicate is two single-quote marks, not a double-quote mark.

A.12.3. Exercise 3 Solution

There are several ways to do this. First, you could create a new static class (such as clsGlobalFriendData) and give it property members that match the data in the Friends data structure and use the property get and set methods to make the data available to clsDB. This would work because a static data item is instantiated at load time so there is always one (and only one) instance of the class. You could then copy the data from frmAddFriend into the static class object and then let clsDB retrieve it. While this works, it means that you always have a copy of that object hanging around chewing up resources when you may not need it. Also, there's just something about that approach that seems "messy" . . . sorta like using an H-bomb to kill an ant.

A less H-bombish approach would be to copy the contents of each textbox object into a string array and pass that string array to a new InsertFriend() ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Navigating the Metaverse

Navigating the Metaverse

Cathy Hackl, Dirk Lueth, Tommaso Di Bartolo, John Arkontaky, Yat Siu
How to Develop a Great Digital Strategy

How to Develop a Great Digital Strategy

Jeanne W. Ross, Cynthia M. Beath, Ina M. Sebastian
Capitalism at Risk

Capitalism at Risk

Joseph L. Bower, Herman B. Leonard, Lynn S. Paine

Publisher Resources

ISBN: 9780470261293Purchase book