Internal connection and introduction to shape language Please use speaker notes for additional information.

Slides:



Advertisements
Similar presentations
Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Advertisements

Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2: Relational Databases.
ActiveX Data Object ISYS 562. ADO An ActiveX control ActiveX is build upon COM, a contract that defines a standard interface by which objects communicate.
Using ADO Programmatically The Connection Object, Command Object, and Recordset Object.
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.
Using Objects and Properties
Object-Oriented Application Development Using VB.NET 1 Chapter 13 Introduction to Data Access Classes and Persistence.
CIS 338: Printing Dr. Ralph D. Westfall February, 2003.
Designing a Database Unleashing the Power of Relational Database Design.
Programming the RecordSet Object
Using ADO Programmatically The Connection Object and the Command Object.
DATA Control. Data Control caption Get first Get previous Get next Get last.
Component 8, Slide 1 CP2030 Visual basic for C++ Programmers, ‘The VB Team’ Copyright © University of Wolverhampton CP2030 Visual Basic For C++ Programmers.
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.
Handling of data from multiple databases. Visual Basic Database Visual Basic application acts as a front-end to the database Visual Basic application.
Copyright © 2001 by Wiley. All rights reserved. Chapter 10: Advanced Database Operations Revising Vintage Videos Setting RecordSource at run time DBGrid.
Interacting with Databases Chapter 10. VB and Databases u It is often useful to have a VB program access data stored in a file other than a text file.
McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 11 Accessing Database.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 11 Committed to Shaping the Next Generation of IT Experts. Chapter 10 Customizing a Database.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with MSSQL Server Code:G0-C# Version: 1.0 Author: Pham Trung Hai CTD.
1 By: Nour Hilal. Microsoft Access is a database software where data is stored in one or more Tables. A Database is a group of related Tables. Access.
ADO 2.5 Kamaljit Bath, Program Manager Data Access Group.
Faculty of Electronic Engineering 1 Database Access API’s Aleksandar Stanimirović Leonid Stoimenov Aleksandar Milosavljević.
Visual Basic ADO Programming 56:150 Information System Design.
Random Files Please see speaker notes for additional information!
Chapter 10 - VB.Net by Schneider1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Relational Databases and SQL.
ActiveX Data Objects (ADO) is Microsoft’s latest database object model. The goal of ADO is to allow VB developers to use a standard set of objects to refer.
Notes on ADO from other projects Please use speaker notes for additional information!
Reference: “ASP.NET 2.0 Illustrated” by Alex Homer and Dave Sussman. -ch3 illustrated book
Two Forms Please use speaker notes for additional information!
Chapter 21: Working with Large Data Re-Visited Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
Lab 8 Data Access Using Microsoft ActiveX Data Object (ADO)
Visual Basic I/O Programs (ProjRead1, ProjRead2, ProjWrite1, ProjPay) Please use speaker notes for additional information!
1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Editing and Designing Databases.
More on Primary and Foreign Keys Please see speaker notes for additional information!
Relational Database in Access Student System As always please use speaker notes!
What’s new in ADO 2.5 Greg Hinkel Program Manager Data Access Group
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.
Source = Table rsObject.Open tablename, Connection Object, CursorType, LockType, adCmdTable Source = Stored Procedure rsObject.Open stored procedure name,
The Windows Forms DataGrid A Complex-Bound.NET GUI Control Mike FITZSIMON SYSTEMSARCHITECT F ITZSIMON IT C ONSULTING PTY LTD.
Using a Database Access97 Please use speaker notes for additional information!
1 ADO Activex Data Objects. 2 ADO ADO allows users to access data easily from many existing databases (such as Access or Paradox) From ODBC compliant.
Mark Dixon 1 Soft051 Examination Sample Questions.
Unbound data fields, find, filter etc. using Data Environment Please use speaker notes for additional information!
ADO and DataList, DataCombo and DataGrid Controls Please use speaker notes for additional information!
 2 Data Object Library approaches ◦ DAO (Data Access Objects)  Original access strategy (up to VB6)  Closely linked to MS Access ◦ ADO (ActiveX Data.
Visual Basic - Break Processing
Processing multiple files
Visual Basic Database Programming.
ADO VBA Programming in Access
Find, filter etc with connection to Access code internally
Data Environment and Grouped Report
Database vs. DBMS Database Database Management System
Objectives Query for top values Create a parameter query
IS444: Modern tools for applications development
IS444: Modern tools for applications development
MICROSOFT VISUAL BASIC
Please use speaker notes for additional information!
Please see speaker notes for additional information!
VB.NET Using Database.
Please use speaker notes for additional information!
Database Fundamentals
Department Array in Visual Basic
Introduction to Computers
Introduction to Views and Reports
Report using ADO connection
Environment/Report Tutorial
Excel Import data from Access to Excel (ADO) using VBA
Please see speaker notes for additional information!
Presentation transcript:

Internal connection and introduction to shape language Please use speaker notes for additional information

PrStuHier.vbp - version with internal code

From student table. From major table. From student course table.

Dim comStuHier As ADODB.Connection Dim rsStudent00 As ADODB.Recordset Dim StuCoursesInfo As ADODB.Recordset Dim MajorInfo As ADODB.Recordset Dim msgstr As String PrStuHier.vbp - version with internal code Dim the connection and the recordsets. Private Sub Form_Load() Dim DBPath As String DBPath = App.Path If Right(DBPath, 1) <> "\" Then DBPath = DBPath & "\" End If DBPath = DBPath & "studentrel00.mdb" Set comStuHier = New ADODB.Connection 'Difference in connection string provider because using the shape language 'Provider is MSDataShape and there is a Data Provider which is the Microsoft.Jet.OLEDB.4.0 With comStuHier.ConnectionString = "Provider = MSDataShape;" & _ "Data Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Persist Security Info=False;" & _ "Data Source=" & DBPath.Open End With 'Set...new loads object into memory Set the connection associated with the Dim statement above.

'Set...new loads object into memory Set rsStudent00 = New ADODB.Recordset Dim SQLCmd As String 'Note the use of { which is a brace with Shape and the use of ({ which is parenthesis brace ' 'Appending a field for each select to each row of the primary recordset which is Student00 'Each appended field is a reference to the matching records in the secondary tables SQLCmd = "SHAPE {SELECT * FROM student00} AS Student00 " & _ "APPEND ({SELECT * FROM major00} AS Major00 " & _ "RELATE 'majorcode' TO 'majorcode') AS Major00, " & _ "({SELECT * FROM stucourse00} AS StuCourses00 " & _ "RELATE 'studentidno' TO 'studentidno') AS StuCourses00" 'Note the SQLCmd is a shape language statement that creates a single hierarchical data set 'from the 3 tables referenced in the shape command With rsStudent00.CursorLocation = adUseClient.CursorType = adOpenDynamic.LockType = adLockOptimistic.Open SQLCmd, comStuHier,,, adCmdText End With Continue Form_Load This code deals with the rsStudent00 recordset.

From version of PrStuHier.vbp that was done using the data environment.

Continue Form_Load 'This gets the entire row from the major00 table Set MajorInfo = rsStudent00.Fields("Major00").Value Set StuCoursesInfo = rsStudent00.Fields("StuCourses00").Value 'Binding the textboxes to the data in the recordset Set txtstudentidno.DataSource = rsStudent00 Set txtname.DataSource = rsStudent00 Set txtmajorcode.DataSource = rsStudent00 Set txtmajorname.DataSource = MajorInfo 'Deals with the data grid With dgdCourses Set.DataSource = StuCoursesInfo.Columns(0).Caption = "Stu ID #".Columns(1).Caption = "Crs Cd".Columns(2).Caption = "Semester".Columns(3).Caption = "Grade".Refresh End With 'Deals with the flex grid Set flxStuHier.DataSource = rsStudent00 End Sub Dim comStuHier As ADODB.Connection Dim rsStudent00 As ADODB.Recordset Dim StuCoursesInfo As ADODB.Recordset Dim MajorInfo As ADODB.Recordset Dim msgstr As String These are the Dim statements from the General area. MajorInfo and StuCourseInfo are getting information from the hierarchy that was created using the Shape language. For example, note that in the Set MajorInfo you use Major00 which comes from rsStudent00. This code establishes the data grid as having StuCoursesInfo as its data source. The captions are also added to the grid. The majorname is gotten from MajorInfo so the set statement establishes it as the data source. The data source for the flex grid is the rsStudent00 hierarchy that was created.

'Binding the textboxes to the data in the recordset Set txtstudentidno.DataSource = rsStudent00 txtstudentidno.DataField = "studentidno" 'The DataField is set in the properties - if it wasn't, I could use the code above. Alternate code:

Set txtmajorname.DataSource = MajorInfo 'txtmajorname.DataField = "majorname" 'Another example of the alternative of putting it into the code. Alternate code:

Private Sub cmdFirst_Click() rsStudent00.MoveFirst End Sub Private Sub cmdLast_Click() rsStudent00.MoveLast End Sub Private Sub cmdNext_Click() rsStudent00.MoveNext If rsStudent00.EOF Then rsStudent00.MoveLast End If End Sub Private Sub cmdPrevious_Click() rsStudent00.MovePrevious If rsStudent00.BOF Then rsStudent00.MoveFirst End If End Sub Navigation code

'Deals with the data grid With dgdCourses Set.DataSource = StuCoursesInfo.Columns(0).Caption = "Stu ID #".Columns(1).Caption = "Crs Cd".Columns(2).Caption = "Semester".Columns(3).Caption = "Grade".Refresh End With

'Appending a field for each select to each row of the primary recordset which is Student00 'Each appended field is a reference to the matching records in the secondary tables SQLCmd = "SHAPE {SELECT * FROM student00} AS Student00 " & _ "APPEND ({SELECT * FROM major00} AS Major00 " & _ "RELATE 'majorcode' TO 'majorcode') AS Major00, " & _ "({SELECT * FROM stucourse00} AS StuCourses00 " & _ "RELATE 'studentidno' TO 'studentidno') AS StuCourses00" 'Note the SQLCmd is a shape language statement that creates a single hierarchical data set 'from the 3 tables referenced in the shape command With rsStudent00.CursorLocation = adUseClient.CursorType = adOpenDynamic.LockType = adLockOptimistic.Open SQLCmd, comStuHier,,, adCmdText End With... 'Deals with the flex grid Set flxStuHier.DataSource = rsStudent00 Appears at the bottom of the Form_Load routine.

With flxStuHier Set.DataSource = rsStudent00.RowHeight(0) = 0.ColHeader(0) = flexColHeaderOn.ColHeaderCaption(0, 1) = "Stu ID#".ColWidth(1, 0) = 650.ColHeaderCaption(0, 2) = "Name".ColWidth(2, 0) = 1800.ColHeaderCaption(0, 3) = "City".ColHeader(1) = flexColHeaderOn.ColWidth(4, 0) = 0.ColHeaderCaption(1, 0) = "Maj Cd".ColWidth(0, 1) = 600.ColHeaderCaption(1, 1) = "Major Name".ColWidth(1, 1) = 1800.ColHeaderCaption(1, 2) = "Major Advisor".ColWidth(2, 1) = 1800.ColHeader(2) = flexColHeaderOn.ColWidth(0, 2) = 0.ColHeaderCaption(2, 1) = "Course Cd".ColHeaderCaption(2, 2) = "Sem. Taken".ColHeaderCaption(2, 3) = "Grade" End With By setting the RowHeight on the 0 row to a height of 0, I make the established headers go away. Now I turn the flexColHeaderOn for each of the three bands (band 0 through band 2) and then set the column width and caption. Note that when setting the caption, you use band, column in parenthesis and when setting the width you use column, band in parenthesis. Set the width to 0 and you will not see the column.

Alternate program

SQLCmd = "SHAPE {SELECT * FROM student00} AS Student00 " & _ "APPEND ({SELECT * FROM major00} AS Major00 " & _ "RELATE 'majorcode' TO 'majorcode') AS Major00, " & _ "({SELECT * FROM stucourse00} AS StuCourses00 " & _ "RELATE 'studentidno' TO 'studentidno') AS StuCourses00" SQLCmd = "SHAPE {SELECT studentidno, name, city, majorcode FROM student00} AS Student00 " & _ "APPEND ({SELECT majorcode, majorname, advisor FROM major00} AS Major00 " & _ "RELATE 'majorcode' TO 'majorcode') AS Major00, " & _ "({SELECT * FROM stucourse00} AS StuCourses00 " & _ "RELATE 'studentidno' TO 'studentidno') AS StuCourses00" This shows two possible SHAPE commands. One selects all of the data from student00, the other selects just specified fields from student00. That is the one that was in effect for this program. Alternate version of the program continued