Introduction |
|
1 | (1) |
|
|
2 | (1) |
|
What Does This Book Cover? |
|
|
2 | (1) |
|
What Do I Need to Use This Book? |
|
|
3 | (1) |
|
|
3 | (1) |
|
|
4 | (5) |
|
How to Download the Sample Code for the Book |
|
|
4 | (1) |
|
|
5 | (1) |
|
|
5 | (1) |
|
|
6 | (1) |
|
Why This System Offers the Best Support |
|
|
6 | (3) |
|
|
9 | (16) |
|
Installing MSDE with the .NET Framework |
|
|
10 | (2) |
|
Installing the .NET Framework |
|
|
10 | (2) |
|
Installing MSDE and the Sample Databases |
|
|
12 | (1) |
|
Installing MSDE with Visual Studio.NET |
|
|
12 | (1) |
|
Connecting to MSDE using MS Access |
|
|
13 | (3) |
|
|
15 | (1) |
|
|
15 | (1) |
|
SQL Server Authentication |
|
|
16 | (1) |
|
|
16 | (1) |
|
|
16 | (3) |
|
Tables, Columns, Rows, and Relationships |
|
|
17 | (2) |
|
Connecting using the Server Explorer |
|
|
19 | (4) |
|
The limitations of Visual C# Standard Edition |
|
|
22 | (1) |
|
|
23 | (2) |
|
A Simple Data-Driven Application |
|
|
25 | (18) |
|
|
25 | (3) |
|
Establishing Contact with the Database |
|
|
28 | (3) |
|
|
31 | (8) |
|
|
39 | (2) |
|
|
41 | (1) |
|
|
41 | (2) |
|
|
43 | (24) |
|
|
43 | (1) |
|
|
44 | (5) |
|
Running SQL Statements from Visual Studio .NET |
|
|
45 | (2) |
|
Running SQL from the Command Line |
|
|
47 | (2) |
|
|
49 | (1) |
|
|
49 | (8) |
|
|
49 | (3) |
|
|
52 | (3) |
|
|
55 | (2) |
|
|
57 | (2) |
|
|
57 | (2) |
|
|
59 | (1) |
|
|
59 | (1) |
|
|
60 | (2) |
|
|
62 | (1) |
|
|
62 | (1) |
|
|
63 | (1) |
|
|
63 | (1) |
|
|
63 | (1) |
|
Restoring the Northwind Database |
|
|
64 | (1) |
|
|
65 | (1) |
|
|
65 | (2) |
|
|
67 | (26) |
|
|
67 | (3) |
|
|
67 | (1) |
|
|
68 | (1) |
|
ADO.NET and the .NET Framework |
|
|
69 | (1) |
|
|
70 | (16) |
|
|
72 | (2) |
|
SQL Server .NET Data Provider |
|
|
74 | (5) |
|
|
79 | (3) |
|
|
82 | (4) |
|
Components of .NET Data Providers |
|
|
86 | (3) |
|
|
86 | (1) |
|
|
87 | (1) |
|
|
87 | (1) |
|
|
87 | (1) |
|
|
88 | (1) |
|
|
89 | (1) |
|
|
90 | (3) |
|
Connecting to the Database |
|
|
93 | (32) |
|
Connection Objects in .NET Data Providers |
|
|
93 | (1) |
|
Connecting to MSDE with SqlConnection |
|
|
94 | (10) |
|
Debugging Connections to SQL Server |
|
|
99 | (2) |
|
Connecting to a SQL Server on Another Server Machine |
|
|
101 | (1) |
|
Security and Passwords in SqlConnection |
|
|
101 | (1) |
|
How to Use SQL Server Security |
|
|
102 | (1) |
|
Connection String Clauses in SqlConnection |
|
|
102 | (2) |
|
|
104 | (1) |
|
Improving Your Use of Connection Objects |
|
|
104 | (7) |
|
Using the Connection String in the Connection Object Constructor |
|
|
104 | (1) |
|
Use finally for Closing Connections |
|
|
104 | (3) |
|
Displaying Connection Information |
|
|
107 | (4) |
|
Connecting to Microsoft Access with OleDbConnection |
|
|
111 | (3) |
|
Connecting to Oracle with OleDbConnection |
|
|
114 | (1) |
|
Connecting to MySQL with OdbcConnection |
|
|
115 | (3) |
|
Connecting to Oracle with OracleConnectlon |
|
|
118 | (3) |
|
|
121 | (1) |
|
|
122 | (3) |
|
|
125 | (32) |
|
Creating a Command Object |
|
|
126 | (4) |
|
Associating a Command with a Connection |
|
|
128 | (1) |
|
Assign a Command Text to a Command Object |
|
|
129 | (1) |
|
|
130 | (3) |
|
Executing Commands with Multiple Results |
|
|
133 | (2) |
|
Executing Non-Query Commands |
|
|
135 | (8) |
|
|
139 | (2) |
|
|
141 | (2) |
|
|
143 | (5) |
|
Using Command Objects in Other .NET Data Providers |
|
|
148 | (6) |
|
|
154 | (1) |
|
|
154 | (3) |
|
|
157 | (26) |
|
Getting to Know ADO.NET Data Readers |
|
|
157 | (1) |
|
Under the Hood of the DataReader |
|
|
158 | (14) |
|
|
162 | (3) |
|
Using Column-Name Indexers |
|
|
165 | (1) |
|
Using Typed Accessor Methods |
|
|
166 | (6) |
|
Learning More about the Data |
|
|
172 | (3) |
|
Getting Schema Information for a DataReader |
|
|
175 | (4) |
|
Using Multiple Resultsets in a DataReader |
|
|
179 | (1) |
|
|
180 | (1) |
|
|
181 | (2) |
|
The DataSet and DataAdaoter |
|
|
183 | (28) |
|
|
184 | (3) |
|
DataSets versus Data Readers |
|
|
184 | (1) |
|
A Brief Introduction to DataSets |
|
|
184 | (2) |
|
Getting Acquainted with the DataAdapter |
|
|
186 | (1) |
|
|
186 | (1) |
|
DataTables, DataColumns, and DataRows |
|
|
187 | (1) |
|
Working with DataSets and DataAdapters |
|
|
187 | (17) |
|
|
188 | (3) |
|
Filtering and Sorting in the DataSet |
|
|
191 | (4) |
|
|
195 | (2) |
|
Modifying Data in the DataSet |
|
|
197 | (3) |
|
Persisting changes to the data store |
|
|
200 | (1) |
|
|
200 | (1) |
|
|
201 | (1) |
|
|
201 | (1) |
|
|
202 | (1) |
|
|
203 | (1) |
|
|
204 | (2) |
|
Typed and Untyped DataSets |
|
|
206 | (1) |
|
|
207 | (1) |
|
|
208 | (3) |
|
Data and Windows Applications |
|
|
211 | (26) |
|
|
212 | (10) |
|
|
212 | (2) |
|
|
214 | (3) |
|
Data Binding - Behind the scenes |
|
|
217 | (1) |
|
Synchronizing Controls with the Data Source |
|
|
218 | (4) |
|
|
222 | (6) |
|
|
222 | (1) |
|
|
223 | (3) |
|
|
226 | (1) |
|
|
227 | (1) |
|
|
228 | (3) |
|
Updating the Data Source Using a DataGrid |
|
|
231 | (3) |
|
|
234 | (1) |
|
|
235 | (2) |
|
|
237 | (38) |
|
|
237 | (15) |
|
|
238 | (6) |
|
|
244 | (2) |
|
Binding Data to a DataGrid |
|
|
246 | (1) |
|
|
247 | (3) |
|
Combining the DataGrid and DataSet |
|
|
250 | (2) |
|
The ASP.NET Page Lifecycle |
|
|
252 | (10) |
|
|
253 | (2) |
|
|
255 | (5) |
|
|
260 | (2) |
|
|
262 | (10) |
|
|
266 | (2) |
|
|
268 | (2) |
|
|
270 | (2) |
|
|
272 | (1) |
|
|
272 | (3) |
|
Validating Web-Based User Input |
|
|
275 | (26) |
|
|
279 | (1) |
|
|
279 | (1) |
|
Disabling Client-Side Validation |
|
|
279 | (1) |
|
|
279 | (1) |
|
Validation in the Page Life Cycle |
|
|
280 | (1) |
|
ASP.NET Validation Controls |
|
|
280 | (16) |
|
The RangeValidator Control |
|
|
281 | (4) |
|
The CompareValidator Control |
|
|
285 | (1) |
|
The RegularExpressionValidator Control |
|
|
286 | (2) |
|
The CustomValidator Control |
|
|
288 | (3) |
|
ValidationSummary Control |
|
|
291 | (4) |
|
Using In-Line and Summary Errors |
|
|
295 | (1) |
|
|
296 | (1) |
|
|
297 | (1) |
|
|
298 | (3) |
|
|
301 | (28) |
|
|
301 | (6) |
|
|
302 | (3) |
|
|
305 | (1) |
|
|
306 | (1) |
|
|
307 | (9) |
|
|
307 | (1) |
|
|
308 | (1) |
|
|
308 | (1) |
|
|
309 | (2) |
|
|
311 | (1) |
|
|
312 | (3) |
|
|
315 | (1) |
|
|
315 | (1) |
|
|
316 | (10) |
|
|
326 | (1) |
|
|
327 | (2) |
|
|
329 | (26) |
|
Northwind Query Application, Part II |
|
|
330 | (5) |
|
|
335 | (17) |
|
|
335 | (1) |
|
|
336 | (1) |
|
|
336 | (3) |
|
|
339 | (1) |
|
|
340 | (2) |
|
|
342 | (1) |
|
|
343 | (2) |
|
|
345 | (1) |
|
|
346 | (2) |
|
|
348 | (1) |
|
|
348 | (2) |
|
|
350 | (1) |
|
|
350 | (2) |
|
|
352 | (1) |
|
|
353 | (2) |
|
Views and Stored Procedures |
|
|
355 | (36) |
|
|
355 | (11) |
|
|
360 | (6) |
|
|
366 | (23) |
|
Working With Stored Procedures in C# |
|
|
376 | (13) |
|
|
389 | (1) |
|
|
389 | (2) |
|
|
391 | (30) |
|
|
391 | (15) |
|
Taking Advantage of Indexes |
|
|
395 | (1) |
|
|
395 | (1) |
|
|
396 | (1) |
|
|
396 | (1) |
|
Maintaining a Unique Column |
|
|
396 | (1) |
|
|
397 | (1) |
|
|
397 | (1) |
|
Indexes and Data Modification |
|
|
398 | (1) |
|
|
398 | (2) |
|
|
400 | (1) |
|
Covering Queries with an Index |
|
|
400 | (1) |
|
Matching Index Search Criteria |
|
|
401 | (2) |
|
Additional Index Guidelines |
|
|
403 | (1) |
|
|
403 | (1) |
|
|
404 | (1) |
|
|
404 | (1) |
|
|
404 | (1) |
|
|
405 | (1) |
|
|
405 | (1) |
|
|
406 | (11) |
|
|
406 | (1) |
|
|
407 | (2) |
|
|
409 | (2) |
|
|
411 | (1) |
|
Check Constraints and Existing Values |
|
|
411 | (1) |
|
Check Constraints and NULL Values |
|
|
412 | (1) |
|
Restrictions On Check Constraints |
|
|
412 | (1) |
|
|
413 | (1) |
|
|
414 | (1) |
|
|
415 | (1) |
|
|
415 | (1) |
|
|
415 | (2) |
|
|
417 | (1) |
|
|
418 | (3) |
|
Authentication and Authorization |
|
|
421 | (26) |
|
|
422 | (1) |
|
Introduction to Database Security |
|
|
422 | (1) |
|
|
423 | (2) |
|
Windows Authentication Mode |
|
|
424 | (1) |
|
Mixed Mode Authentication |
|
|
425 | (1) |
|
|
425 | (10) |
|
|
425 | (2) |
|
Adding and Removing Login Entries |
|
|
427 | (1) |
|
|
427 | (1) |
|
|
428 | (1) |
|
|
429 | (1) |
|
|
429 | (1) |
|
|
430 | (1) |
|
|
431 | (1) |
|
|
431 | (1) |
|
|
432 | (1) |
|
|
433 | (1) |
|
|
434 | (1) |
|
|
435 | (8) |
|
|
436 | (1) |
|
|
436 | (1) |
|
|
436 | (1) |
|
Resolving Permission Conflicts |
|
|
437 | (1) |
|
|
438 | (1) |
|
|
439 | (1) |
|
|
440 | (3) |
|
|
443 | (1) |
|
|
444 | (1) |
|
|
445 | (2) |
|
|
447 | (20) |
|
|
447 | (2) |
|
The Structure of an XML Document |
|
|
449 | (3) |
|
|
452 | (4) |
|
|
455 | (1) |
|
|
456 | (4) |
|
Application Configuration Using XML |
|
|
460 | (4) |
|
|
464 | (1) |
|
|
465 | (1) |
|
|
465 | (2) |
|
Handling ADO.NET and Database Exceptions |
|
|
467 | (26) |
|
General Exception Handling in C# |
|
|
468 | (3) |
|
The Generic Exception Class |
|
|
469 | (2) |
|
|
471 | (1) |
|
ADO.NET Exceptions and Database Exceptions |
|
|
471 | (1) |
|
|
472 | (1) |
|
|
473 | (8) |
|
|
481 | (9) |
|
|
490 | (1) |
|
|
491 | (2) |
|
|
493 | (30) |
|
When to Use/ When Not To Use Transactions |
|
|
494 | (1) |
|
|
495 | (1) |
|
|
496 | (22) |
|
Working with SQL Transactions |
|
|
496 | (13) |
|
|
509 | (1) |
|
|
510 | (1) |
|
|
511 | (1) |
|
ADO.NET Transaction Code Guidelines |
|
|
511 | (7) |
|
|
518 | (1) |
|
|
519 | (1) |
|
|
520 | (3) |
|
|
523 | (24) |
|
|
523 | (2) |
|
Adding and Removing Event Handlers |
|
|
525 | (1) |
|
|
525 | (18) |
|
|
526 | (1) |
|
|
526 | (5) |
|
|
531 | (4) |
|
|
535 | (6) |
|
Working With Multiple Handlers |
|
|
541 | (2) |
|
|
543 | (1) |
|
|
544 | (3) |
|
|
547 | (46) |
|
SQL Server Data Types for Irregular Data |
|
|
548 | (1) |
|
Advantages/Disadvantages of Irregular Data Types |
|
|
548 | (1) |
|
Storing Images in a Database |
|
|
549 | (16) |
|
Displaying Images With Headers |
|
|
561 | (4) |
|
Extracting Binary Data to Files |
|
|
565 | (7) |
|
Working with Large Text Files |
|
|
572 | (9) |
|
Retrieving Data from Large Text Columns |
|
|
578 | (3) |
|
Irregular Data In Other ADO.NET Data Providers |
|
|
581 | (8) |
|
Irregular Data Type Enumeration Differences Between Providers |
|
|
583 | (4) |
|
Irregular Data in the ODBC.NET Data Provider |
|
|
587 | (2) |
|
|
589 | (1) |
|
|
590 | (3) |
Appendix A: The Custom Query Tool Application |
|
593 | (12) |
Appendix B: XML Primer |
|
605 | (14) |
|
|
605 | (14) |
|
|
605 | (1) |
|
|
605 | (1) |
|
|
606 | (1) |
|
|
607 | (1) |
|
Structure of an XML Document |
|
|
608 | (1) |
|
|
608 | (1) |
|
Well-formed and Valid XML |
|
|
609 | (1) |
|
|
610 | (1) |
|
|
610 | (9) |
Index |
|
619 | |