vb科学计算机ppt,计算机科学与技术:VB.NET应用教程 教学课件 作者 978-7-302-09622-1Advanced VB.NET Chapter 10.ppt...

本教程讲解了使用VB.NET进行数据库操作的方法,包括SQL查询构建、数据读取、参数使用及事务管理等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

a7f4a3f590493a1e451dd952a488fd7c.gif 计算机科学与技术:VB.NET应用教程 教学课件 作者 978-7-302-09622-1Advanced VB.NET Chapter 10.ppt

(70页)

5f8316caeac3494365feaa154b05b7df.gif

本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦!

9.90 积分

Chapter 10The Connected Layer Command and Data Reader Classes 1Copyright 2004 Pearson Education, Inc.ObjectivesA Quick Review of Essential SQL with the Query BuilderThe SQL Select CommandThe Command ClassThe Data ReaderMore Properties and MethodsThe XML ReaderReading the Database SchemaParameters and the Command ObjectManaging TransactionsBrief Look at Stored ProceduresLab 10: The Command, DataReader, and Parameter ClassesSuggested Home Assignments2Copyright 2004 Pearson Education, Inc.Opening The Query BuilderRecall how this window is openedin Chapter 93Copyright 2004 Pearson Education, Inc.The Query BuilderAdd table to SQLChange SQL to a Group By Select queryCheck SQL syntaxRun SQL Dhow Results PaneShow SQL Pane Show Grid Pane Show Diagram PaneDiagram PaneGrid Pane SQL Pane Results Pane 4Copyright 2004 Pearson Education, Inc.The Query BuilderChange hereSee change automatically appear here5Copyright 2004 Pearson Education, Inc.The Query Builder1. Click here2. And the code will appear here and here.3. Or, add item here and it will be marked in the diagram pane and added to the SQL pane.6Copyright 2004 Pearson Education, Inc.ObjectivesA Quick Review of Essential SQL with the Query BuilderThe SQL Select CommandThe Command ClassThe Data ReaderMore Properties and MethodsThe XML ReaderReading the Database SchemaParameters and the Command ObjectManaging TransactionsBrief Look at Stored ProceduresLab 10: The Command, DataReader, and Parameter ClassesSuggested Home Assignments7Copyright 2004 Pearson Education, Inc.The Select CommandSelects rows and columns from a table.Columns can be limited by specifying only the wanted ones.Rows can be limited through a Where clause.Select * From Friends Select ID, FirstName, LastName From Friends Select ID, FirstName, LastName From Friends Where LastName = “Smith” 8Copyright 2004 Pearson Education, Inc.The Select CommandThe results can be sorted with the Order By clause. By default order is in ascending order. To make the order descending add the keyword DESC. With several items in the Order By, the sort order will be by the first item and within it be the second item, and so on. Select ID, FirstName, LastName From Friends Where LastName = “Smith” Order By ID, FirstName DESC 9Copyright 2004 Pearson Education, Inc.ExampleSort Order10Copyright 2004 Pearson Education, Inc.Discussion / ProjectWith the Query Builder,Show all the pets and each pet’s owner.The pets who belong to male friends.Show the age of the friends who have pets,To do this join the Friends and Pets table.Show the age of the male friends who have pets.Show the friends who have both pets and cars.11Copyright 2004 Pearson Education, Inc.Discussion / ProjectWith the Query BuilderShow the friends who are married to each other, To do this join Friends with another copy of Friends and make the join based on Spouse in one table being the same as First Name in the other and make th。省略部分。ommit its changes to the database or to rollback all the changes.myTransaction.Commit() myTransaction.Rollback() 62Copyright 2004 Pearson Education, Inc.ObjectivesA Quick Review of Essential SQL with the Query BuilderThe SQL Select CommandThe Command ClassThe Data ReaderMore Properties and MethodsThe XML ReaderReading the Database SchemaParameters and the Command ObjectManaging TransactionsBrief Look at Stored ProceduresLab 10: The Command, DataReader, and Parameter ClassesSuggested Home Assignments63Copyright 2004 Pearson Education, Inc.Stored ProceduresA subroutine that is stored in the database and activated just as SQL statements are.Access does not support these. 64Copyright 2004 Pearson Education, Inc.Building a Stored Procedure' Build a stored procedure myCommand.CommandType = CommandType.Text ' The SQL statement below will build a stored' procedure when it is executed. myCommand.CommandText = _ "Create Procedure myProcedure1 AS " & _ " Select * From Friends ; " ' Execute the SQL statement to build the stored ' procedure. myCommand.ExecuteNonQuery() 65Copyright 2004 Pearson Education, Inc.Calling a Stored Procedure' Set the Command object to call the stored procedure myCommand.CommandType = CommandType.StoredProceduremyCommand.CommandText = "myProcedure1" ' Call the stored procedure and place the results ' in a Data Reader. myReader = myCommand.ExecuteReader _ (CommandBehavior.SequentialAccess)66Copyright 2004 Pearson Education, Inc.ObjectivesA Quick Review of Essential SQL with the Query BuilderThe SQL Select CommandThe Command ClassThe Data ReaderMore Properties and MethodsThe XML ReaderReading the Database SchemaParameters and the Command ObjectManaging TransactionsBrief Look at Stored ProceduresLab 10: The Command, DataReader, and Parameter ClassesSuggested Home Assignments67Copyright 2004 Pearson Education, Inc.Lab 10 The Command, Data Reader, and Parameters Classes 68Copyright 2004 Pearson Education, Inc.ObjectivesA Quick Review of Essential SQL with the Query BuilderThe SQL Select CommandThe Command ClassThe Data ReaderMore Properties and MethodsThe XML ReaderReading the Database SchemaParameters and the Command ObjectManaging TransactionsBrief Look at Stored ProceduresLab 10: The Command, DataReader, and Parameter ClassesSuggested Home Assignments69Copyright 2004 Pearson Education, Inc.Suggested Home AssignmentBuild a new form that will receive as a parameter the name of a friend and will return all that friend’s pets from the Friends database. The list of pets should be presented in a List Box. Build a new form that will receive as a parameter a year and will return the number of friends born that year from the Friends database. Build a new form that will receive as a parameter a year and will return the pet names that contain the letter “A” that belong to friends born that year from the Friends database. 70Copyright 2004 Pearson Education, Inc. 关 键 词: vb.net vb net advanced 应用 1advanced 教程 作者 302 978

4d91c43bfc72ca913299809b07b4968f.gif  天天文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。

关于本文

本文标题:计算机科学与技术:VB.NET应用教程 教学课件 作者 978-7-302-09622-1Advanced VB.NET Chapter 10.ppt

链接地址: https://www.wenku365.com/p-50213511.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值