Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ASP .NET Database Programming Weekend Crash Course - J. Butler, T. Caudill.pdf
Скачиваний:
31
Добавлен:
24.05.2014
Размер:
3.32 Mб
Скачать

 

Contents

Preface .....................................................................................................................

v

Introduction ..........................................................................................................

xvii

FRIDAY...................................................................................................................

2

Part I—Friday Evening .......................................................................................

4

Session 1–Introducing ASP.NET ..................................................................................

5

Internet Standards .............................................................................................

5

The Evolution of ASP ..........................................................................................

6

The Benefits of ASP.NET ......................................................................................

8

What Is .NET? ....................................................................................................

9

.NET Experiences ........................................................................................................

9

.NET Clients .............................................................................................................

10

.NET Services ...........................................................................................................

10

.NET Servers .............................................................................................................

10

.NET Tools ................................................................................................................

11

Session 2–Setting Up .NET ......................................................................................

13

Installation Requirements ..................................................................................

13

Installing ASP.NET and ADO.NET ..........................................................................

15

Installing the .NET Framework SDK .............................................................................

15

Testing Your Installation ....................................................................................

17

Support for .NET ..............................................................................................

19

Session 3–Designing a Database ..............................................................................

21

Designing a Database ........................................................................................

21

Normalization of Data .......................................................................................

24

Security Considerations .....................................................................................

26

Session 4–Building a Database ................................................................................

29

Creating a Database ..........................................................................................

29

Creating SQL Server Tables .................................................................................

32

Creating a View ................................................................................................

37

Creating a Stored Procedure ...............................................................................

37

Creating a Trigger .............................................................................................

38

SATURDAY ...........................................................................................................

44

Part II—Saturday Morning ..............................................................................

46

Session 5–Using SQL: A Primer ................................................................................

47

INSERT Statements ...........................................................................................

47

DELETE Statements ...........................................................................................

49

UPDATE Statements ..........................................................................................

50

SELECT Statements ...........................................................................................

51

Session 6–XML: A Primer .........................................................................................

55

The XML Design Specs .......................................................................................

55

The Structure of XML Documents .........................................................................

56

XML Syntax .....................................................................................................

58

XML and the .NET Framework .............................................................................

59

Session 7–Developing ASP.NET Pages ........................................................................

61

ASP.NET Events ................................................................................................

61

Page Directives ................................................................................................

64

Namespaces .....................................................................................................

66

Choosing a Language ........................................................................................

67

x

Contents

Session 8–Using HTML Controls ...............................................................................

69

Introducing HTML Controls .................................................................................

70

Using HTML controls .................................................................................................

70

How HTML controls work ...........................................................................................

74

Intrinsic HTML controls .............................................................................................

74

HTML Control Events .........................................................................................

74

The Page_OnLoad event .............................................................................................

75

Custom event handlers ..............................................................................................

76

Session 9–Using Web Controls .................................................................................

79

Intrinsic Controls .............................................................................................

80

Using intrinsic controls .............................................................................................

80

Handling intrinsic Web control events .........................................................................

83

List Controls ....................................................................................................

84

Rich Controls ...................................................................................................

85

Session 10–Introducing User Controls ......................................................................

89

Creating a User Control ......................................................................................

90

Adding User Control Properties ...........................................................................

92

Writing Custom Control Methods .........................................................................

94

Implementing User Control Events ......................................................................

95

Part III—Saturday Afternoon ...........................................................

100

Session 11–Validating User Input ..........................................................................

101

Common Aspects of Validation Controls ..............................................................

102

Display property .....................................................................................................

102

Type Property .........................................................................................................

103

Operator Property ...................................................................................................

103

Using Validation Controls .................................................................................

103

RequiredFieldValidator .............................................................................................

104

RegularExpressionValidator ......................................................................................

105

CompareValidator ....................................................................................................

106

RangeValidator .......................................................................................................

108

CustomValidator ......................................................................................................

109

ValidationSummary .................................................................................................

111

Session 12–Maintaining State in ASP.NET ...............................................................

113

Maintaining State Out of Process for Scalability ...................................................

113

No More Cookies but Plenty of Milk! ..................................................................

115

Advantages ........................................................................................................

115

Disadvantages ....................................................................................................

115

How to make it happen ........................................................................................

115

Out of Process State Management ......................................................................

118

Session Management with SQL Server ........................................................................

118

Advantages ........................................................................................................

118

Disadvantages ....................................................................................................

118

How to make it happen ........................................................................................

119

Session Management with ASP.NET State Server ..........................................................

120

Advantages ........................................................................................................

120

Disadvantages ....................................................................................................

120

How to make it happen ........................................................................................

121

Session 13–Authentication and Authorization .........................................................

123

Introducing the Key Security Mechanisms ..........................................................

123

Web.config and Security ...................................................................................

124

Special identities ....................................................................................................

127

Using request types to limit access ...........................................................................

128

New Tricks for Forms-based Authentication .........................................................

128

Contents

xi

132

135

136

136

136

137

137

140

142

143

143

144

145

146

146

149

149

150

150

151

151

151

152

152

152

155

168

169

170

171

174

177

178

179

180

180

181

181

183

183

183

184

187

187

189

189

189

190

191

193

193

193

194

xii

Contents

GetOrdinal method ..................................................................................................

194

GetName method ....................................................................................................

194

Close method .........................................................................................................

194

Session 20–Introducing DataSets, Part I .................................................................

197

Constructing a DataAdapter Object .....................................................................

199

SelectCommand property .........................................................................................

200

UpdateCommand, DeleteCommand, and InsertCommand properties ...............................

201

Fill method ............................................................................................................

201

Update method .......................................................................................................

203

Dispose method ......................................................................................................

203

Using DataSet Objects ......................................................................................

203

DataSetName property .............................................................................................

203

CaseSensitive property ............................................................................................

204

SUNDAY.............................................................................................................

208

Part V—Sunday Morning ...............................................................................

210

Session 21–Introducing DataSets, Part II ................................................................

211

Constructing a DataSet .....................................................................................

211

Tables property .......................................................................................................

212

TablesCollection Object ....................................................................................

214

Count property .......................................................................................................

214

Item property .........................................................................................................

214

Contains method .....................................................................................................

215

CanRemove method .................................................................................................

216

Remove method ......................................................................................................

216

Add method ...........................................................................................................

216

DataTable Objects ............................................................................................

216

CaseSensitive property ............................................................................................

217

ChildRelations property ...........................................................................................

217

Columns property ...................................................................................................

217

Constraints property ...............................................................................................

218

DataSet property ....................................................................................................

218

DefaultView property ..............................................................................................

218

ParentRelations property .........................................................................................

218

PrimaryKey property ...............................................................................................

218

Rows property ........................................................................................................

219

Dispose method ......................................................................................................

221

NewRow method ....................................................................................................

221

Session 22–Introducing Data Binding .....................................................................

223

What Is Data Binding? .....................................................................................

223

Binding to Arrays and Extended Object Types ......................................................

224

Binding to Database Data .................................................................................

226

Binding to XML ..............................................................................................

227

TreeView Control ............................................................................................

228

Implement the TreeView server control ......................................................................

229

Session 23–Using the DataGrid Control with Bound Data ..........................................

233

DataGrid Control Basics ....................................................................................

233

Binding a set of data to a DataGrid control ................................................................

233

Formatting the output of a DataGrid control ..............................................................

235

Master/Detail Relationships with the DataGrid Control ..........................................

236

Populating the Master control ..................................................................................

238

Filtering the detail listing ........................................................................................

239

Session 24–Beating the CRUD out of the DataGrid Control .......................................

243

Updating Your Data .........................................................................................

243

Contents

xiii

246

247

247

248

248

249

250

255

255

258

258

259

263

265

267

267

268

269

276

277

277

278

281

281

282

283

284

287

291

291

292

293

294

295

296

296

296

297

297

297

298

299

299

300

302

304

309

309

310

311

312

312

313

xiv

Contents

Appendix B–What’s on the CD-ROM ........................................................................

315

System Requirements ......................................................................................

315

Using the CD with Windows ..............................................................................

316

What’s on the CD ............................................................................................

316

Author-created materials .........................................................................................

316

The Software Directory ....................................................................................

316

Applications ...........................................................................................................

317

eBook version of ASP.NET Database Programming Weekend Crash Course ........................

318

Troubleshooting .............................................................................................

318

Appendix C–ADO.NET Class Descriptions .................................................................

319

Appendix D–Coding Differences in ASP and ASP.NET ................................................

355

Retrieving a Table from a Database ....................................................................

355

How you did it with VBScript in ASP .........................................................................

355

How you do it with VB .NET in ASP.NET .....................................................................

355

How you do it with C# in ASP.NET .............................................................................

356

Displaying a Table from a Database ....................................................................

356

How you did it with VBScript in ASP .........................................................................

356

How you do it with VB .NET in ASP.NET .....................................................................

357

How you do it with C# in ASP.NET .............................................................................

358

Variable Declarations .......................................................................................

358

How you did it with VBScript in ASP .........................................................................

358

How you do it with VB .NET in ASP.NET .....................................................................

359

How you do it with C# in ASP.NET .............................................................................

359

Statements ....................................................................................................

359

How you did it with VBScript in ASP .........................................................................

359

How you do it with VB .NET in ASP.NET .....................................................................

359

How you do it with C# in ASP.NET .............................................................................

359

Comments .....................................................................................................

359

How you did it with VBScript in ASP .........................................................................

359

How you do it with VB .NET in ASP.NET .....................................................................

360

How you do it with C# in ASP.NET .............................................................................

360

Indexed Property Access ..................................................................................

360

How you did it with VBScript in ASP .........................................................................

360

How you do it with VB .NET in ASP.NET .....................................................................

360

How you do it with C# in ASP.NET .............................................................................

360

Using Arrays ..................................................................................................

360

How you did it with VBScript in ASP .........................................................................

360

How you do it with VB .NET in ASP.NET .....................................................................

361

How you do it with C# in ASP.NET .............................................................................

361

Initializing Variables .......................................................................................

361

How you did it with VBScript in ASP .........................................................................

361

How you do it with C# in ASP.NET .............................................................................

362

If Statements .................................................................................................

362

How you did it with VBScript in ASP .........................................................................

362

How you do it with VB .NET in ASP.NET .....................................................................

362

How you do it with C# in ASP.NET .............................................................................

362

Case Statements .............................................................................................

363

How you did it with VBScript in ASP .........................................................................

363

How you do it with VB .NET in ASP.NET .....................................................................

363

How you do it with C# in ASP.NET .............................................................................

363

For Loops ......................................................................................................

364

How you did it with VBScript in ASP .........................................................................

364

How you do it with VB .NET in ASP.NET .....................................................................

364

How you do it with C# in ASP.NET .............................................................................

364

Contents

xv

364

364

364

365

365

365

365

365

365

365

366

366

366

366

366

366

369

387