Introduction to ADO, VB Database Tools and Data .ppt
《Introduction to ADO, VB Database Tools and Data .ppt》由会员分享,可在线阅读,更多相关《Introduction to ADO, VB Database Tools and Data .ppt(33页珍藏版)》请在麦多课文档分享上搜索。
1、Introduction to ADO.Net, VB.Net Database Tools and Data Binding,ISYS 512,Client/Server Structure,a. Presentation user interface Menus, forms, reports, etc b. Processing logic Business rules c. Database,Client,Database Server,SQL queries,Results,Database Processing,Querying database Updating database
2、: Insertion, deletion, modification,Steps to Retrieve Data,Establishes a connection to the database. Executes commands against the database. Store data results.,A Simplified View of ADO.Net Objects,Ado.Net,Data Provider,Connection,Adapter,Command,Reader,Dataset,Data Consumer,WinForm,WebForm,ADO.NET
3、Objects,Connection Object: Represent a connection to the database. Command Object: The command object allows us to execute a SQL statement or a stored procedure. DataReader: It is a read-only and forward-only pointer into a table to retrieve records. DataSet Object: A DataSet object can hold several
4、 tables and relationships between tables. DataAdapter: This the object used to pass data between the database and the dataset.,Data Providers,ODBC Provider Open Database Connectivity A driver manager Used for relational databases OLE DB Provider OLE DB interfaces provide applications with uniform ac
5、cess to data stored in diverse information sources, or data stores. Access SQL Server Provider Oracle Provider,Using ODBC,Windows XP: Control Panel /Administrative Tools/DataSource(ODBC) Three types of data source names User DSN: usable only by you and only on the machine currently using. System DSN
6、: Any one using the machine can use. File DSN: Can be copied and used by other computers with the same driver installed. Demo: Excel: Data/Import Access: File/Get External Data/Import, then select ODBC data source,VB.NET Database Tools,Database connection: Tools/Connect to database Data Source Serve
7、r Explorer Data connections: Right click data connection Add Connection Tables, Views Create new SQL Server Database Toolbox:Data tab Data/Add New Data Source,Creating SQL Server Database,From Server Explorer, right click data connection and choose: Create new SQL Server Database Server name: LocalS
8、erverNameSQLExpress Add new table: Right click Tables and choose Add New Table Add rows: Right click the table name and choose Show table data. Note: After creating the database, you may create an ODBC DSN to connect to it.,How to create ADO.Net objects?,Automatically generated when creating data bo
9、und form. Form wizard Using Data Adapter Wizard Using code: Example: dim strConn as string =“Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:sales2k.mdb“ dim objConn as new OledbConnection(strConn) objConn.open(),Data Binding,Connect a control or property to one or more data elements. Simple bindin
10、g: Use simple binding to display a field value in controls that show Data Bindings in the property window, such as text box or label. Complex binding: Use complex binding to bind more than one field to controls such as DataGrid and list box. Use the controls Data Source and Data Member to bind the d
11、ata.,Creating Data Bound Form,Creating a form with ADO.Net objects and data-bound controls to display and update information in a dataset. Demo: Add data source: Data/Add New Data Source Data/Show Data Source Click the dropdown list next to the tables name: Datagrid view Details Drag the table to fo
12、rm.,Items Added to the Form,Connection Table Adapter: click smart tag Add query Preview data Dataset: Edit in dataset designer Binding Source Add query: Add a new tool strip. Preview data Binding navigator Code view: Form load event,Generated Code,Private Sub CUSTOMERBindingNavigatorSaveItem_Click(B
13、yVal sender As System.Object, ByVal e As System.EventArgs) Handles CUSTOMERBindingNavigatorSaveItem.ClickMe.Validate()Me.CUSTOMERBindingSource.EndEdit()Me.CUSTOMERTableAdapter.Update(Me.SalesDBDataSet.CUSTOMER) End SubPrivate Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
14、 Handles MyBase.LoadTODO: This line of code loads data into the SalesDBDataSet.CUSTOMER table. You can move, or remove it, as needed.Me.CUSTOMERTableAdapter.Fill(Me.SalesDBDataSet.CUSTOMER) End Sub,Other Data Form Demos,DataGrid View Add /Modify/Delete records. Read only form: Delete AddNew, Delete,
15、 Save buttons from navigator bar.,Hierarchical Forms,Parent table/Child table Add parent table and child table to Data Source Drag the parent table and the child table to the form. Parent table uses detail view and child table uses dataGrid view Click Dataset objects smart tag to choose Edit in Data
16、set Designer With the designer, right click the parent table and choose Add/Relation Change dataGrids DataSource property to the relation.,Detail Form with Bound ListBox,Example: Customer table form with CID listbox and displays selected customer information in textboxes. Choose detail view for the
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- INTRODUCTIONTOADO VBDATABASETOOLSANDDATAPPT

链接地址:http://www.mydoc123.com/p-376623.html