FOR 240 Homework Assignment 4 Using DBGridView and Other VB Controls to Manipulate Database Introduction to Computing in Natural Resources

Similar documents
17. Introduction to Visual Basic Programming

How to use data sources with databases (part 1)

In this tutorial we will create a simple calculator to Add/Subtract/Multiply and Divide two numbers and show a simple message box result.

How to work with data sources and datasets

ADO.NET 2.0. database programming with

Chapter 2 Exploration of a Visual Basic.Net Application

To enter the number in decimals Label 1 To show total. Text:...

A Complete Tutorial for Beginners LIEW VOON KIONG

IMS1906: Business Software Fundamentals Tutorial exercises Week 5: Variables and Constants

Lab 4: Adding a Windows User-Interface

Form Adapter Example. DRAFT Document ID : Form_Adapter.PDF Author : Michele Harris Version : 1.1 Date :

Learning VB.Net. Tutorial 17 Classes

PROGRAMMING ASSIGNMENT: MOVIE QUIZ

Learning VB.Net. Tutorial 19 Classes and Inheritance

To get started with Visual Basic 2005, I recommend that you jump right in

Learning VB.Net. Tutorial 10 Collections

MATFOR In Visual Basic

1. Create your First VB.Net Program Hello World

How to Validate DataGridView Input

Connection Example. Document ID : Connection_Example.PDF Author : Michele Harris Version : 1.1 Date :

Else. End If End Sub End Class. PDF created with pdffactory trial version

If this is the first time you have run SSMS, I recommend setting up the startup options so that the environment is set up the way you want it.

GUI Design and Event- Driven Programming

Access Review. 4. Save the table by clicking the Save icon in the Quick Access Toolbar or by pulling

Objectives. After completing this topic, the students will: Understand of the concept of polymorphism Know on How to implement 2 types of polymorphism

Question: How do I move my mobile account from the Corporate to my Personal Account?

IRESS Depth - Web Services Version 4 Walkthrough Visual Basic 2008 sample to retrieve IRESS Depth information

IOS Plus Trade - Web Services Version 4 Walkthrough

Learning VB.Net. Tutorial 15 Structures

โปรแกรมช วยทดสอบหม อแปลงกระแส

Filtering - Zimbra

C4.3, 4 Lab: Conditionals - Select Statement and Additional Input Controls Solutions

Learning Studio Tool & Microsoft Outlook

Hands-On Lab. Getting Started with Office 2010 Development. Lab version: Last updated: 2/23/2011

Disclaimer. Trademarks. Liability

Microsoft Office Outlook 2007: Intermediate Course 01 Customizing Outlook

COPYRIGHTED MATERIAL. Visual Basic: The Language. Part 1

Tutorial 03 understanding controls : buttons, text boxes

DO NOT COPY AMIT PHOTOSTUDIO

Programming with ADO.NET

[Not for Circulation] This document provides information regarding using tasks in Microsoft Outlook 2007.

Click on OneDrive on the menu bar at the top to display your Documents home page.

The first program we write will display a picture on a Windows screen, with buttons to make the picture appear and disappear.

Moodle 2.2 Student User Guide My Private Files

Sending, Composing and Addressing a New Message:

Chapter 2 Visual Basic, Controls, and Events. 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual Basic Events

Mr.Khaled Anwar ( )

Coordinator of Education and Training Programs

Outlook calendar guide

Running the Altair SIMH from.net programs

Window (further define the behaviour of objects)

Lab 3 The High-Low Game

PLU Sale Functionality (Including PLU Sale Import) V7.3

Search & Rescue Map Specifications and Production Workflows

Revision for Final Examination (Second Semester) Grade 9

VISUAL BASIC II CC111 INTRODUCTION TO COMPUTERS

超音波モータ制御プログラムの作成 (v1.2.1)

FOR 240 Lab 8 Assignment Using GPS to Collect Spatial Data of Forest Management Introduction to Computing in Natural Resources

GroupWise 7 Devereux User s Guide

REVIEW OF CHAPTER 1 1

A Second Visual BASIC Application : Greetings

Exercise 1: Assigning Responsibilities to Delegates (This was called Proxy in GroupWise)

Tips for the end-user

CALIFORNIA STATE UNIVERSITY, SACRAMENTO College of Business Administration. MIS 15 Introduction to Business Programming. Programming Assignment 3 (P3)

AscTec FLIR Converter Instructions

Building Datacentric Applications

CT862 Section 1 Introduction

1. Open Outlook by clicking on the Outlook icon. 2. Select Next in the following two boxes. 3. Type your name, , and password in the appropriate

S.2 Computer Literacy Question-Answer Book

The Filter Property Selecting a File The Save Menu The SaveFileDialog Control The Edit Menu The Copy Menu...

Nikon Capture NX "How To..." Series

An Introduction to Google Chrome

Getting Started with Visual Basic.NET

Microsoft Access 2010

How to Create a MindManager Add-in With Visual Studio in 7 Steps

Microsoft Office Outlook 2010

Microsoft Access 2013

Microsoft Access 2013

INTRODUCTION TO VISUAL BASIC 2010

2. Click New in the upper left corner of the standard toolbar (along the top) to open a new message box.

Form Connection. Imports System Imports System.Threading Imports System.IO.Ports Imports System.ComponentModel

Learning VB.Net. Tutorial 16 Modules

Module 8: Building a Windows Forms User Interface

Visual Basic 6 includes many tools to help you create, revise, manage, and

Unit 3. Lesson Designing User Interface-2. TreeView Control. TreeView Contol

Plan Submittals. City of Port St Lucie, MIS Department 5/29/2015

Windows 7 Control Pack for WinForms

Fairfield University Using Xythos for File Storage

Hands-On Lab. Lab: Client Object Model. Lab version: Last updated: 2/23/2011

Microsoft Access 2013

More Skills 11 Capture a Screen with the Snipping Tool

Join Queries in Cognos Analytics Reporting

Savoy ActiveX Control User Guide

Student Manual. Cognos Analytics

Quick Tips & Tricks. Important You must use SEMICOLONS ( ie; ) to separate address when sending mail to multiple users

SCRIPT REFERENCE. UBot Studio Version 4. The Browser Commands

Mail Home Tab Junk Mail Options..5 Turning a message into meeting.6 Moving Messages...6 Creating a Rule...7

LFCDS SkyMail & SkyDrive. Full Student Orientation

BRIEFCASES & TASKS ZIMBRA. Briefcase can be used to share and manage documents. Documents can be shared, edited, and created using Briefcases.

To complete this project, you will need the following folder:

Transcription:

FOR 240 Homework Assignment 4 Using DBGridView and Other VB Controls to Manipulate Database Introduction to Computing in Natural Resources This application demonstrates how a DataGridView control can be used to display a table of information from a database. VB makes it easy to access database information from within your application. The data control provides the ability to navigate through the database recordset, synchronizing the display of records in the grid control with the position in the recordset. The following controls are needed in this application: DataGridView control Command button The database we are going to use is timbercruising.accdb created in the database application section. The recordset is table tblplot in the database. Creating a Project You begin creating the application by choosing New Project from the File menu, then selecting Windows Forms Application in the New Project dialog box (when you first start Visual Basic, the New Project dialog box is presented). VB creates a new project and displays a new form. Now we need to design the interface. Follow the steps to add DataGridView and add datasource: a. Select DataGridView under the group Data in the Toolbox, and drag it to the form interface. By default, the control will be named as DataGridView1. b. Highlight DataGridView1 and click the right arrow on the top of the control to add data source to it. c. In the pop-up dialogue, expand the Choose Data Source options and click Add Project Data Source (Figure 16.6). d. Select Database and click Next button (Figure 16.7). e. Click New Connection, select Microsoft Access Data File, and browse the folder to locate your database that you will use in the project (Figure 16.8). In this case, I select 2007Database.accdb, which is the database you created in labs 5 and 6, and should be saved in the same folder of the project. Click OK. Go ahead to save the connection (Figure 16.9). f. In Figure 16.10, select the table that you want to display using DataGridView. In this case, I choose tblplot. FOR 240 Homework 3 1

Figure 16.6. Add Project Data Source. Figure 16.7. Choose a data source type. (a) FOR 240 Homework 3 2

(b) (c) (d) Figure 16.8. Define data connection. FOR 240 Homework 3 3

Figure 16.9. Save conncection. Figure 16.10. Choose source table. Once everything is set up, your design interface should look like Figure 16.11. You also need to add a command button on the form. Now, save your project with a name of prjfirstapp. FOR 240 Homework 3 4

Figure 16.11. Design interface. Setting Properties In the Properties window, set properties for the objects according to Table 16.2. Use the default settings for all other properties. Table 16.2. Property settings of the objects. Object Property Setting Form Name frmcourse Text Firstapp DataGridView1 Name DBGridCourse Text Courses DataSource datacourse Button1 Name cmdclose Text Close Writing Event Code Double-click the form or control to display the Code window, and then type the code for each event procedure. Add the code to cmdclose_click event procedure to end the application when you click Close button. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click End End Sub Since we have defined data source for DataGridView1, Visual Studio 2010 automatically generate code for the form load event. FOR 240 Homework 3 5

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the '_2007DatabaseDataSet.tblPlot' table. You can move, or remove it, as needed. Me.TblPlotTableAdapter.Fill(Me._2007DatabaseDataSet.tblPlot) End Sub Again, save your project at this point. Running the Project There are two ways that you can use to run the application: a. From Run menu, click Start b. From toolbar, click the button Start Your application will be in the running mode (Figure 16.12). Figure 16.12. Running the application. You may need to test your program: a. Add new courses b. Edit existed courses c. Delete a course d. Close your application Please provide me a typed summary report together with code listing and your output form (Figure 16.12) by the beginning of the lab next week. FOR 240 Homework 3 6