Ch. 101 DataTable Data Table Object A DataTable object holds the contents of a table as a rectangular array. A data table is similar to a two-dimensional.

Slides:



Advertisements
Similar presentations
MS-Word XP Lesson 7.
Advertisements

Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
© Paradigm Publishing, Inc Access 2010 Level 1 Unit 2Creating Forms and Reports Chapter 6Creating Reports and Mailing Labels.
Benchmark Series Microsoft Access 2010 Level 1
Chapter 5 Multitable Forms
MS-Access XP Lesson 2. Input Mask Property 1.Field : Phone No Data Type : Number Input Mask : Character 0 represent a single digit and phone.
PRIMARY, SECONDARY & QUANTITATIVE RESEARCH TASK HYPERLINK APPLICATION PROCEDURE 1.
Microsoft Office 2010 Access Chapter 1 Creating and Using a Database.
Access Lesson 2 Creating a Database
Access - Project 1 l What Is a Database? –A Collection of Data –Organized in a manner to allow: »Access »Retrieval »Use of That Data.
1 Web-Enabled Decision Support Systems Advance Topics in Database Connectivity Prof. Name Position (123) University Name.
Ch. 101 Virtual Table and DataGridView Virtual Table DataGridView.
Microsoft Office 2007 Access Chapter 2 Querying a Database.
Ch. 101 Changing the Contents of a Database. Ch. 102 Changing the Contents of a Database Data grid views can also be used to add, modify, and delete records.
Introduction to Data Adapter. A Simplified View of ADO.Net Objects Ado.Net Data Provider Connection Adapter Command Reader Dataset Data Consumer WinForm.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
COMPREHENSIVE Access Tutorial 2 Building a Database and Defining Table Relationships.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 1 Creating and Using a Database.
Microsoft Visual Basic 2012 CHAPTER TEN Incorporating Databases with ADO.NET.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 3 Maintaining a Database Using the Design and Update Features of Access.
Microsoft Access 2007 Microsoft Access 2007 Introduction to Database Programs.
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Chapter 2 Querying a Database
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
WORKING WITH MACROS CHAPTER 10 WORKING WITH MACROS.
Chapter 10 - VB.Net by Schneider1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Relational Databases and SQL.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Chapter 11 Introduction to Database Processing. Class 11: Database Processing Use a Visual Studio Wizard to establish a database connection used to load.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
You can use a query to view a subset of your data or to answer questions about your data. For example, if you want to view a list of student names and.
Ch VB 2008 by Schneider1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Relational Databases and SQL.
Chapter 1 Databases and Database Objects: An Introduction
P RACTICE Determine the output displayed when the button is clicked. Dim actor(5,5) As String Private Sub btnDisplay_Click(...) Handles btnDisplay.Click.
Using Arrays and File Handling
Chapter 6 Advanced Report Techniques
CIS 451: Using ASP.NET Objects with SQL Dr. Ralph D. Westfall February, 2009.
® Microsoft Office 2013 Access Building a Database and Defining Table Relationships.
Microsoft Office Access 2003 Số tiết: 30 tiết lý thuyết 60 tiết thực hành Giáo viên: Từ thị Xuân Hiền.
1/36 Database Programming with Visual Basic.Net and MS Access IKE Lab. Yunho Song Database Management and Analysis.
Course ILT Access basics Unit objectives Define database and database-related terminology, and plan a database Start Access and open, create, view, and.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Microsoft Office 2007 Access Chapter 2 Querying a Database.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
® Microsoft Office 2010 Building a Database and Defining Table Relationships.
1 Chapter 12 – Web Applications 12.1 Programming for the Web, Part I 12.2 Programming for the Web, Part II 12.3 Using Databases in Web Programs.
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Access Project 7 Advanced Report and Form Techniques.
Chapter 10 - VB.Net by Schneider1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Relational Databases and SQL.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 1 Creating and Using a Database.
Spreadsheet Data Tables Data Table 1 allows you to change one input variable’s value at a time and record the impact that the input assumption has on several.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 25.1 Test-Driving the ATM Application 25.2.
Ch. 101 Database Management An Introduction to Databases.
1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Editing and Designing Databases.
ADO.NET in VB.NET 2005 ITE 370 4/26/2017.
Ch VB 2005 by Schneider1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Relational Databases and SQL.
ADO.NET Objects Data Adapters Dr. Ron Eaglin. Agenda Builds on Information in Part I Should have working knowledge of creating a database connection Continuation.
COMPREHENSIVE Access Tutorial 1 Creating a Database.
Ch. 101 DataTable (Continue) Lab sheet 10.3: Form Display Cities table along with percentage growth.
Access Chapter 2 Querying a Database.
CIS16 Application Programming with Visual Basic
Chapter 10 – Database Management
Accessing Databases with ADO.NET, Handling Exceptions, and Printing
Defining the Fields in a Table
Presentation transcript:

Ch. 101 DataTable Data Table Object A DataTable object holds the contents of a table as a rectangular array. A data table is similar to a two-dimensional array; it has rows and columns.

Ch. 102 Important Note Two steps for each program in order to gain access to the Data Table object. 1.Add references to System.Data.dll and System.Xml.dll. (Next slide) 2.Type the statement Imports System.Data at the top of the code window.

Ch. 103 Add references to System.Data.dll and System.Xml.dll. 1.Click on Project in the Menu bar. 2.Click on Add Reference to invoke the “Add Reference” dialog box. 3.Make sure the.NET tab is selected. 4.Click on System.Data. 5.Hold down the Ctrl key and click on System.Xml. 6.Press the OK button.

Ch. 104 Add references to System.Data.dll and System.Xml.dll. (1) (2) (3) (4) (5) (6)

Ch. 105 Data Adapter A data adapter is an intermediary object that serves as a channel to allow bidirectional data transfers between database and dataTable or dataSet Data Adapter Database DataTable

Ch. 106 DataTable Variable We will assume that the two steps discussed in the previous slide (1. add references; 2. Imports system.data) have been carried out for every program in this chapter. Then, the following declares a DataTable variable Dim dt As New DataTable()

Ch. 107 Fill method The Fill method of the DataAdapter fills a DataSet or datatable with data retrieved from a query For example, Dim dt as New dataTable() … dataAdapter.fill(dt)

Ch. 108 Dispose Method It releases all resources used by the DataAdapter. For example, Dim dt as New DataTable() … dataAdapter.Fill(dt) ‘filling data into dt ‘release all resource used by dataAdapter dataAdapter.Dispose()

Ch. 109 Connecting with a DataTable Dim dt As New DataTable() Dim connStr As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=MEGACITIES.MDB" Dim sqlStr As String = "SELECT * FROM Cities" Dim dataAdapter As New _ OleDb.OleDbDataAdapter(sqlStr, connStr) dataAdapter.Fill(dt) dataAdapter.Dispose() (Boiler plate to be inserted into every program in chapter.)

Ch Properties of the DataTable Property CountUsage dt.Rows.Count Number of Records dt.Column.Count Number of columns The records are numbered 0 through dt.Rows.Count – 1 The fields are numbered 0 through dt.Columns.Count – 1

Ch More Properties The name of the j th field is given by dt.Columns(j) The entry in the j th field of the i th record is dt.Rows(i)(j) The entry in the specified field of the i th record is dt.Rows(i)(fieldName)

Ch Lab Lab sheet 10.1

Ch Lab sheet 10.1: Form Display one record at a time from the Cities table.

Ch Lab sheet 10.1: Partial Code Dim dt As New DataTable() Dim rowIndex As Integer = 0 Private Sub frmCities_Load(...) Handles _ MyBase.Load (Last five statements of boilerplate) UpdateTextBoxes() End Sub Sub UpdateTextBoxes() 'Display contents of row specified by rowIndex variable txtCity.Text = CStr(dt.Rows(rowIndex)("city")) txtCountry.Text = CStr(dt.Rows(rowIndex)("country")) txtPop2005.Text = CStr(dt.Rows(rowIndex)("pop2005")) txtPop2015.Text = CStr(dt.Rows(rowIndex)("pop2015")) End Sub

Ch Lab sheet 10.1: Partial Code cont. Private Sub btnNext_Click(...) Handles btnNext.Click 'Show the next record if current one is not the last If (rowIndex < dt.Rows.Count - 1) Then rowIndex += 1 'Increase rowIndex by 1 UpdateTextBoxes() End If End Sub Private Sub btnPrevious_Click(...) Handles _ btnPrevious.Click 'Show previous record if current one is not the first If (rowIndex > 0) Then rowIndex = rowIndex - 1 UpdateTextBoxes() End If End Sub

Ch Lab sheet 10.1: Output