CIS 338: Using Queries in Access as a RecordSource Dr. Ralph D. Westfall May, 2011.

Slides:



Advertisements
Similar presentations
Stored procedures and views You can see definitions for stored procedures and views in the demo databases but you can’t change them. For views, expand.
Advertisements

Microsoft SQL Server 2008 From the Program menu choose: Microsoft SQL Server 2008 R2  SQL Server Management Studio. You may see a window indicating the.
Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 2 Querying a Database Using the Select Query Window.
CIS 338: Printing Dr. Ralph D. Westfall February, 2003.
EGR 141 Computer Problem Solving in Engineering and Computer Science Interfacing with a Database in Visual Basic.NET 2005.
Mary K. Olson PS Reporting Instance – Query Tool 101.
Chapter Extension 6 Using Microsoft Access © 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke.
Exporting Data and Creating Financial Reports with Excel and Crystal Slide 1 Exporting Data and Creating Financial Reports with Excel and Crystal By Peter.
Stored Procedures Dr. Ralph D. Westfall May, 2009.
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Chapter 2 Querying a Database
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Chapter 3 Maintaining a Database
Some Basic Database Terminology
Copyright 2007, Paradigm Publishing Inc. BACKNEXTEND 3-1 LINKS TO OBJECTIVES Save a Filter as a Query Save a Filter as a Query Parameter Query Inner, Left,
© Paradigm Publishing, Inc Access 2010 Level 2 Unit 1Advanced Tables, Relationships, Queries, and Forms Chapter 3Advanced Query Techniques.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
CIS 338: Creating ActiveX Controls Dr. Ralph D. Westfall March, 2003.
Chapter 1 Databases and Database Objects: An Introduction
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
Creating a Web Site to Gather Data and Conduct Research.
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 5 Enhancing Forms with OLE Fields, Hyperlinks, and Subforms.
1 Databound Controls. 2 Objectives You will be able to use design time data binding to display and update SQL Server database data without writing any.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 5 Enhancing Forms with OLE Fields, Hyperlinks, and Subforms.
Microsoft Office 2007 Access Chapter 2 Querying a Database.
Social Science Research Design and Statistics, 2/e Alfred P. Rovai, Jason D. Baker, and Michael K. Ponton Entering Data Manually PowerPoint Prepared by.
Chapter 17 Creating a Database.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
Damian Tamayo Tutorial DTM Data Generator Fall 2008 CIS 764.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Access Project 7 Advanced Report and Form Techniques.
Microsoft Access 2010 Chapter 10 Administering a Database System.
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.
Access Forms and Queries. Entering Data in Your Table  You can add data to your table in Datasheet view, by typing in the columns and rows.  This.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
Databases with LINQ. LINQ to SQL LINQ to SQL uses LINQ syntax to query databases. LINQ to SQL classes are automatically generated by the IDE’s LINQ to.
1 Chapter 20 – Data sources and datasets Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
You can sort Access data so you can view records in the order you want to view them, and you can filter data so you only see the records you want to see.
Gold – Crystal Reports Introductory Course Cortex User Group Meeting New Orleans – 2011.
T7-1 LEARNING OUTCOMES – ACCESS PROBLEM SOLVING 1.Describe the process of using the Simple Query Wizard using Access 2.Describe the process of using the.
Normalizing Database Files Professor Ralph Westfall May, 2011.
1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Editing and Designing Databases.
DAY 18: MICROSOFT ACCESS – CHAPTER 3 CONTD. Akhila Kondai October 21, 2013.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
Understand Databound Controls Windows Development Fundamentals LESSON 4.2A.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
VB.NET and Databases. ADO.NET VB.Net allows you many ways to connect to a database. The technology used to interact with a database or data source is.
Access Queries and Forms. Adding a New Field  To insert a field after you have saved your table, open Access, and open the table  It is easier to add.
CIS 338: VB.NET Printing Dr. Ralph D. Westfall May, 2011.
Creating SQL Database file And Displaying a Database Table in a DataGridView.
Copyright © 2014 Pearson Canada Inc. Ext. 5b-1 Copyright © 2014 Pearson Canada Inc. Application Extension 5b Using Microsoft Access Part 2: Using Information.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Visual Basic 2010 How to Program
Stored Procedures Dr. Ralph D. Westfall May, 2011.
Access Chapter 2 Querying a Database.
Plug-In T7: Problem Solving Using Access 2007
SQL MODELER - OPEN There are Three Ways to open the SQL Modeler
Creating and Modifying Queries
CIS16 Application Programming with Visual Basic
Chapter 1 Databases and Database Objects: An Introduction
Access: Queries IV Participation Project
Presentation transcript:

CIS 338: Using Queries in Access as a RecordSource Dr. Ralph D. Westfall May, 2011

What Is a Query SQL code in a database that gets specific data based on selected fields (columns) selected records (rows) selected (one or more) table(s) in contrast to getting all data from one table

Initial Database Set-Up download dbquery2000.mdb filedbquery2000.mdb for demonstration, NOT for this quarter's project start Microsoft Access open dbquery2000.mdb file if prompted, follow directions to convert database to latest version of Access  might have to convert back later

Creating Queries for Totals click Create tab click Query Design select Payments table, click Add Close the Show Table window

Creating Queries for Totals - 2 double click BldgNo, AcctNo and Payment from Payments table when double clicked, item should go into query table (or can drag & drop) click totals button (Greek letter sigma) on toolbar at top of screen (view effect) click 3rd (Total) line in Payment column and select Sum from drop down list

Creating Queries for Totals - 3 click 3rd (Total) line in AcctNo column and select Where from drop down list put 5401 in Criteria (6th row) of AcctNo column don't need to use a criterion for this quarter's project change to Group By in BldgNo column

Creating Queries for Totals - 4 make sure that Show is checked for all columns except AcctNo close and save as default, Q5401 or [ ] right-click to Open this query to make sure it is getting the data it should could calculate totals in Excel to verify make changes if necessary

Creating Queries for Totals - 5 repeat steps in the preceding 4 slides or copy and paste Query1 twice change the Criteria to 5601 for the 2 nd query, and 5801 the 3 rd query you should now have 3 queries Query1, Query2 and Query3 (or whatever you want to call them)

Setting Up a Combined Query click on Create then click Query Design click Both tab in Show Table window select Buildings table, click Add select the 3 queries you just created, click Add Close the Show Table window

Combined Query - 2 left click, drag and drop BldgNo from Buildings table to BldgNo on 1 st query should result in a connecting line repeat with Buildings table and 2nd query, and then with Buildings table and 3rd query click and drag query tables up and down should see separate connecting lines from Buildings table to each query

Combined Query - 3 right click on line between the Buildings table and the 1 st query select Join Properties click the radio button for 2. (Include all records from 'Buildings' …), then OK left join: all buildings, even if no cost data repeat for line between Buildings table and 2 nd query, and then between Buildings table and 3 rd query

Combined Query - 4 double click BldgNo, Building, and SquareFeet and anything else you need from Buildings table when double clicked, item should go into query table (or can drag & drop) double click SumOfPayment in 1 st query, then in 2 nd and 3 rd queries items should go into query table

Create Calculated Columns in 1 st open column, type: LeasePSF: [Q5401].[SumofPayment]/[SquareFeet] source needs to match query name repeat named as TaxPSF and OtherPSF, using data from 2 nd and 3 rd queries uncheck Show for all 3 SumofPayment columns

Create Calculated Columns - 2 run query note that some cells are blank "null" instead of a zero value buildings where there is no data for that account # null values can cause problems with VB.NET calculations and elsewhere

Create Calculated Columns - 3 getting zeros from Null data create calculated columns with code like LeaseCost: Nz([Q5401].[SumOfPayment], 0) Nz returns 0 for Null numeric data and a zero-length string for a Null text value Nz after this is coded, it is possible to divide [SumOfPayment] by [SquareFeet] to get LeasePSF for all properties run, close and save as Query4 or [ ] Notes

SQL Code Microsoft Access generated SQL code based on the query you just created use View>SQL View to see SQL code could copy and paste this code into VB.NET when need to create SQL statement for Access (or modify to SQL Server syntax)

Ending Database Set-Up if need to use an earlier version of Access in your VB.NET project, convert this database to the previous version under another name e.g., propmgt2.mdb close the database

SQL Server Query Editor third-party toolsthird-party tools can provide capabilities for SQL Server similar to those in Access also see How do you use the Query Designer in SQL Server 2008?How do you use the Query Designer in SQL Server 2008?

Using Queries in VB.NET open VB.NET, start a Windows project Data>Add New Data Source > Database > Next > New Connection > Data source: Change > Microsoft Access Database File > OK > Database file name: Browse > dbquery2000.mdb > Test Connection >OK > OK> [like to copy?] > Next [save the connection?] > Yes > Next > expand Views > [select combined query] > Finish

Using Queries in VB.NET - 2 drag and drop the Combined Query View from Data Sources onto form expand form and DataGridView to show all fields run the project

Query Data Doesn't Update data in this type of query: come from multiple tables include calculated and summary fields changes entered by user in textbox do not go into database queries OK for viewing data, or creating reports, but not good for data entry

Queries as a DataSource add a ListBox to the form set the DataSourceName property browse to find the [query]Binding Source set the DisplayMember property browse to find one of the fields in the query run the code and note how ListBox selections navigate in DataGridView

Expressions in DataSet Schema VB.NET provides capabilities to create formulas inside the schema (.xsd file) arithmetic, concatenation, decoding, etc. less efficient for larger volumes of data, but provides more independence from data sources

Stop Here following slide worked for a previous Visual Studio version

Using Queries in VB.NET - 3 right click [da]>Generate Dataset it may be helpful to rename it to ds be sure to check Add this dataset to the designer, then OK on Toolbox, click Data button then drag a DataView onto the designer in Properties window, rename it (dv1), set its Table property to ds1.QueryCombined