Database Programming with C#

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Need to master database programming in C#? Then Database Programming with C# is your ultimate resource! You will learn to create database details like tables, constraints, projects, stored procedures, views, triggers, and more. You will build on example code from the book's beginning, wrapping up in the final chapter. (The example application is a complete user management system that includes SQL Server, Active Directory, and Message Queuing.) Example code explains connecting and manipulating data in MySQL 3.23.45 and later, Oracle 8i and later, Microsoft Access 2000 and later, and SQL Server. So if you're connecting to SQL Server 2000, you'll find information on the SQLXML 2.0 plug-in for manipulating SQL Server data using XML from managed code or using HTTP. Exchange Server 2000 connection and data manipulation are also covered with original working code.

Author(s): Carsten Thomsen
Edition: 1st
Publisher: Apress
Year: 2002

Language: English
Pages: 520

Table of Contents......Page 2
Database Programming with C#......Page 12
Technology Requirements......Page 15
Feedback......Page 16
Reviewing Programming Concepts......Page 17
A Quick Look at Components of the .NET Framework......Page 18
Assemblies and Namespaces......Page 21
Getting Cozy with the VS .NET Integrated Development Environment......Page 24
Two Interface Modes......Page 25
Command Window......Page 26
Built-in Object Browser......Page 27
Integrated Help System......Page 28
Macros......Page 29
Text Editors......Page 30
Server Explorer......Page 31
Toolbox......Page 32
Summary......Page 33
Why Use a Database?......Page 34
Hierarchical Databases......Page 35
What C# Programmers Need to Know About Relational Databases......Page 36
UserMan Database Schema......Page 47
Summary......Page 48
Overview......Page 49
Data Providers and Drivers......Page 51
.NET Data Providers......Page 53
The Connection Class......Page 54
ConnectionString Property......Page 55
Connection Class Properties......Page 64
Connection Class Methods......Page 66
Connection Class Events......Page 69
Opening a Connection......Page 70
Comparing Two Connection Objects......Page 71
Manipulating the Connection State......Page 72
Pooling Connections......Page 74
Handling Provider, Driver, and Data Source Messages......Page 78
Transactions......Page 79
Handling Connection Class Exceptions......Page 87
Using Command Objects......Page 96
OleDbCommand, OdbcCommand, and SqlCommand......Page 97
Command Class Properties......Page 100
Command Class Methods......Page 106
Executing a Command......Page 107
Handling Command Class Exceptions......Page 109
Using the DataReader Class......Page 111
Declaring and Instantiating a DataReader Object......Page 112
Closing a DataReader......Page 113
Handling Multiple Results......Page 114
DataReader Methods......Page 115
XmlReader......Page 121
XmlReader Properties......Page 122
XmlReader Methods......Page 123
Declaring and Instantiating an XmlReader Object......Page 126
Handling XmlReader Exceptions......Page 127
The DataAdapter Explained......Page 128
DataAdapter Properties......Page 129
DataAdapter Events......Page 130
Instantiating a DataAdapter......Page 131
Setting the Command Properties......Page 133
Handling Fill Operation Errors......Page 137
Handling Row Updates......Page 138
When to Use the CommandBuilder Class......Page 140
Preparing the DataAdapter......Page 141
Summary......Page 142
Using the DataSet Class......Page 144
Recordset vs. DataSet......Page 145
DataSet Properties......Page 146
DataSet Methods......Page 149
DataSet Events......Page 151
Instantiating a DataSet......Page 152
Populating Your DataSet Using the DataAdapter......Page 153
Updating Your Data Source Using the DataAdapter......Page 155
Merging Data in a DataSet with Other Data......Page 157
Detecting and Handling Changes to Data in a DataSet......Page 159
Accepting or Rejecting Changes to Data in a DataSet......Page 161
DataTable Properties......Page 163
DataTable Methods......Page 165
DataTable Events......Page 167
Building Your Own DataTable......Page 168
Copying a DataTable......Page 170
Searching a DataTable and Retrieving a Filtered Data View......Page 171
Copying Rows in a DataTable......Page 172
Handling Column Changes......Page 174
Handling Row Changes......Page 175
Handling Row Deletions......Page 177
DataView Properties......Page 178
DataView Methods......Page 179
DataView Events......Page 180
Searching a DataView......Page 181
Sorting a DataView......Page 182
Using the DataRow Class......Page 183
Declaring and Instantiating a DataRow......Page 185
Using the DataColumn Class......Page 186
Declaring and Instantiating a DataColumn......Page 187
Using the DataRelation Class......Page 188
Declaring and Instantiating a DataRelation......Page 189
Looking at Cursors......Page 194
Cursor Types......Page 195
Pessimistic Locking......Page 197
Optimistic Locking......Page 199
Using "Classic" ADO and COM Interop......Page 205
Summary......Page 206
Handling Data Connections......Page 208
Handling Servers......Page 211
Looking at Database Projects......Page 217
Deleting a Database Project Folder......Page 219
Adding Database Objects to a Database Project......Page 220
Designing Databases with the Database Designer......Page 223
Creating a Database Diagram......Page 224
Adding Columns......Page 229
Adding Indexes and Keys......Page 230
Adding Constraints......Page 231
Designing Queries with the Query Designer......Page 233
Taking a Closer Look at the Query Designer Panes......Page 234
Verifying the SQL Syntax......Page 238
Examining the Various Query Types......Page 239
Script Editing Using the SQL Editor......Page 241
Using the Query Editor to Produce SQL Statements......Page 242
Running SQL Scripts......Page 243
Using the DataSet Designer to Create a Typed Data Set......Page 244
Summary......Page 246
Overview......Page 247
Using Two or More Exception Handlers in One Procedure......Page 248
Examining the Exception Class......Page 249
Handling Exceptions in the Exception Handler......Page 250
Filtering Exceptions......Page 254
Creating Your Own Exception......Page 255
Handling Data-Related Exceptions......Page 256
CLR Handling of Exceptions......Page 257
Enabling Debugging......Page 258
Disabling Debugging......Page 259
Using Debug Assertions......Page 260
Using Debug Error Messages......Page 261
Summary......Page 262
Optimization Issues......Page 263
Troubleshooting Performance Degradation......Page 265
Using Stored Procedures......Page 266
Why Use a Stored Procedure?......Page 267
Creating and Running a Stored Procedure......Page 268
Retrieving a Value Specified with RETURN......Page 277
Running Oracle Stored Procedures......Page 278
Why Use a View?......Page 283
Creating a View......Page 284
Using a View from Code......Page 285
Why Use a Trigger?......Page 288
Creating a Trigger......Page 289
Summary......Page 292
Looking at LDAP......Page 294
Examining the System.DirectoryServices Namespace......Page 295
Studying the DirectoryEntry Class......Page 296
Searching for an Object in Active Directory......Page 300
Manipulating Object Property Values......Page 304
Accessing Active Directory Using the OLE DB .NET Data Provider......Page 307
Specifying What Information to Retrieve from Active Directory......Page 308
Retrieving the SID for a User......Page 309
Accessing Microsoft Exchange Server......Page 310
Using the Microsoft OLE DB Exchange Server Provider......Page 311
Using the Microsoft OLE DB Provider for Internet Publishing......Page 312
Accessing Exchange Server As a Linked Server from SQL Server......Page 314
Summary......Page 318
Connectionless Programming......Page 319
When to Use a Message Queue......Page 320
Creating the Queue Programmatically......Page 322
Displaying or Changing the Properties of Your Message Queue......Page 324
Binding to an Existing Message Queue......Page 326
Sending a Message......Page 327
Retrieving a Message......Page 328
Peeking at Messages......Page 331
Picking Specific Messages from a Queue......Page 332
Retrieving All Messages in a Queue......Page 333
Sending and Retrieving Messages Asynchronously......Page 334
Clearing Messages from the Queue......Page 335
Prioritizing Messages......Page 337
Locating a Message Queue......Page 338
Removing a Message Queue......Page 340
External Transactions......Page 341
Starting a Transaction......Page 342
Using the MessageQueueTransaction Class......Page 343
Looking at System-Generated Queues......Page 345
Using Journal Storage......Page 346
Using Authentication......Page 349
Using Encryption......Page 352
Using Access Control......Page 355
Summary......Page 358
Looking at Object Oriented Programming......Page 359
Inheritance......Page 360
Encapsulation......Page 362
C# Keywords Related to OOP......Page 363
Creating the CUser Class......Page 365
Summary......Page 373
Data-Bound Controls vs. Manual Data Hooking......Page 374
Using Data-Bound Controls with Windows Forms......Page 375
Using Data-Bound Controls with Web Forms......Page 386
Summary......Page 397
Database Objects......Page 398
Active Directory Object......Page 408
Creating a Windows Client......Page 410
Database Suggestions......Page 411
General Suggestions......Page 412
Summary......Page 413
Overview......Page 414
Installing SQLXML 2.0......Page 417
Configuring the ISAPI Extension......Page 418
Restarting the Virtual Directory Application......Page 423
Inspecting the SQLXML 2.0 Managed Classes......Page 431
Summary......Page 449
Symbols and Numbers......Page 450
Index......Page 478
Appendix A: Using XML with SQL Server 2000......Page 506