30
On Visual Basic ADO Data Control

Ado Visual Basic

Embed Size (px)

DESCRIPTION

Project

Citation preview

Page 1: Ado Visual Basic

OnVisual Basic

ADO Data Control

Submitted To :

Submitted By : Asiya Rehman

Page 2: Ado Visual Basic

Every work. However big or small is a result of join effort

of a lot of people. This Project is also the same

First of all I would like to thanks our principal

Mrs. Reena Francis for her efforts provide us a harmonious

environment our thanks go to respected faculties for providing

me useful literature and books at the time of crisis.

In the end I am also thankful to our Ms. Shabeena Malik

for there Guidance and kind co-operation. It would have been

impossible for me to complete this project report without her help

and valuable suggestion providing me useful literature & books at

the time of crisis

Student

Asiya Rehman

Page 3: Ado Visual Basic

CertificateThis is to certify that Asiya Rehman studying in Class 12 Section “B” in academic session 2012-13 of the institution has completed project report on “Computer ” as requirement of practical exam The work has been carried to our entire satisfaction under our guidance and supervision.

Lecturer in charge Principal

Ms Shabeena Malik

Date

Grade

Page 4: Ado Visual Basic

INDEX

INTRODUCTION

INTRODUCTION ORGANIZATION PROFILE

SYSTEM DESIGN AND DEVELOPMENT

INTRODUCTION TO SYSTEM DESIGN PHASES OF SDLC

BRIEF INTRODUCTION TO SOFTWARE USED

WINDOWS 98 OR UPPER VERSION VISUAL BASIC AS FRONT-END MS-ACCESS

ADO CONTROL

HARDWARE AND SOFTWARE REQUIREMENTS

BIBLIOGRAPHY

Page 5: Ado Visual Basic

INTRODUCTION TO SYSTEM DESIGN

System design is a solution, a “how to” approach to the creation of the new system. This important phase is composed of the several steps. It provides the understandings and procedural details necessary for implementing the system recommended in feasibility study. Emphasis is on translating the performance requirements into design specification. Design goes through logical and physical stages of development. Logical designs reviews the present physical system, prepares input and output specification, make edit security and control specification, details the implementation plan and prepares a logical design walkthrough. The physical design makes out the details of the physical system, plans the system implementation devices a test and implementation plan and specifies any new hardware and software.

Implementation, planning, system test preparation, system interfaces specification and user documentation.

1. Data Base Design: - This activity deals with the design of the physical database. A key is to determine how the access paths are to be implemented. A physical path is derived from a logical path.

2. Programs Design: - In conjunction with the database design is a decision on the programming language to be used and the flowcharting and debugging procedure prior to conversion.

3. Systems and Programs Test Preparation: - Each aspect of the system has a separate test requirement. System testing is done after all programming and testing are completed the test cases cover every aspect of the candidate system actual operation, user interface and so on.

4. System Interface Specification: - This phase specifies for the user how information should enter and leave the system.

Page 6: Ado Visual Basic

ERROR HANDLING

Input Design: Inaccurate input data are the most common cause of error in data processing. To identify and correct errors the following must be done.

DEVELOPMENT ACTIVITIES:-

Several development activities are carried out during structured design.

Those are following:-1 Process of design

The design phase focuses on the detail implementation of the system recommended in the feasibility study. Emphasis is on translating the performance specifications into design specifications. The design phase is a transition from a user-oriented document to a document oriented to the programmers or data base personnel.

2 Requirements of form design

i. Identification and wording.ii. Maximum readability and use.iii. Physical factor.iv. Order of data items.v. Ease of data entry.vi. Size and arrangement forms.vii.Use of instructions.Viii.Efficiency considerations.

1. Output Design: -

Computer outputs are most important and direct source of information to the user. Efficient, intelligible output design should improve the system’s relationship with the user and

Page 7: Ado Visual Basic

help in decision making. A major form of output in a hard copy from the printer. Printout should be designed around the output requirement of the user.

2. Form design:- The data, the forms carry come from

people and the informational output the system goes to the people. The physical carrier of data of information. It also can constitute authority for action. Each from is a request for an action. It provides information for making decision and improving operations. Manipulate, describe and manage data.

e. Testing:-No system design is ever perfect. A system is tested for online

response, volume of transaction, stress, recovery from failure and usability. System testing requires a test plan that consists of several key activities and steps for programs, string, system and user acceptance testing. Testing is the process to check the system to find out any error that many cause the system some trouble or hamper the integrity of the data.

PREPERATION OF THE TEST PLAN

Software testing is the process of executing a program with the intent of finding an error. A good test has a high probability of finding a yet undiscovered error. The test data was prepared keeping in mind the user requirement and expectation.

METHOD USED TO TEST DATA

1. Test data was keened in through the data entry screen in the database.

2. Input/output was carried to ensure proper functioning of the system. It was confirmed that all the required validation and check are performed by giving invalid data input. 3. Testing for suitable error message/messages was done in case of invalid data entry.

4. Testing for proper report layout.

TESTING METHOD

1 UNIT TESTING :- This type of testing involve individual

Page 8: Ado Visual Basic

testing of programs with respect to the desired expected output proper care is taken when entering the data checks were made to see that the data entered is correct and not of the specified bond(s), proper error message are flashed when an error occurs.

2 SYSTEM TESTING: - In this phase the system as a whole is tested. This testing phase will check the integrity of the data while it was transferred from one process to another. The interaction between the modules was checked to see whether a module procedure the required output, which would be needed as input of another one.

e. Implementation: -This is crucial phase of system

development .It involves introduction of new system into operation. This involves creating computer awareness on to job, training, installation of hardware, terminal if does not exist, client communication equipment before the system is up and made operational. User manuals are prepared and user is trained in its use.

Before implementation system was working manually. Few people were developed to run the computerized system. Data was fed at regular interval and monitories on basis of report and output. All the possible errors were recorded rectify and rested. The system after proper security and satisfaction was stepped in to next phase employees were given adequate training, about how to handle the system.

f. Post-implementation and Maintenance:-After the installation phase is

completed and the user staff is adjusted to the changes created by the candidate system, the evaluation and maintenance begin. Like any system, there is an aging process that requires periodic maintenance of Hardware & Software. If the new information is inconsistent with the designed specification then changes have to be incorporated in the Software. Hardware also requires periodic maintenance to keep in tune with designed specification.

Page 9: Ado Visual Basic

TO TO

SOFTWARE USED SOFTWARE USED ABOUT OPERATING SYSTEM

WINDOWS 98

In order to understand the application development process, it is helpful to understand some of the key concepts upon which Visual Basic is build because Visual Basic is a windows development language, so some familiarity with the Windows environment is necessary.

A complete description of the inner working of Windows would require an entire book. A simplified working of the Windows involves three key concepts:-

1 Windows2 Events3 Messages

Windows can be thought of simply as a rectangular region with its own boundaries. There are several different types of Windows:

1 An explorer window in Windows 982 A document window within our word processing program OR3 A dialog box that pops up of remind us of an appointment Icons, Text

boxes, Option buttons and menu bar all Windows.

The Microsoft Windows O .S manages all of these many windows by assigning each one a unique ID no. the system continually

Page 10: Ado Visual Basic

monitors each of these windows for sign of activity or events. Events can occur through user action such as a mouse click or a key press, through programmatic control, or events as a result of another window action.

ABOUT FRONT-ENDABOUT FRONT-END

VISUAL BASIC

The “VISUAL” part refers to the methods used to create the Graphical User Interface (GUI). Rather than writing numerous lines of code we simply drag and drop pre-build objects into place on the screen.

The “BASIC” part refers to the BASIC (Beginners All Purpose Symbolic Instruction Code) language, a language used by more programmers. VB has evolved from original BASIC language and now contains several more than hundred statements, functions and keywords, many of which relate directly to Windows (GUI). Beginners can create useful application by learning just a few of the keywords.

Whether our goal is to create a small utility for our workgroup or a large enterprise-wide system, ourselves or even distributed applications spanning the globe via the Internet, VB has the tool we need.

1 Data access features allow us to create database & front-end application for most popular database formats.

2 ActiveX technology allows us to use the functionality provided by other applications, such as Microsoft Word word processor, Microsoft Excel spreadsheet and other Windows application.

3 Internet capabilities make it easy to provide access to documents and applications across the Internet from within our document.

4 Our finished application is true .exe file that uses a runtime Dynamic Link Library (DLL) that we can freely distribute.

UNDERSTANDING THE EVENT DRIVEN MODEL

Page 11: Ado Visual Basic

In traditional or procedural applications the application itself controls which portion of the code to execute and in which sequence. In an event driven application, the code does not follow a predetermined path it executes different code sections in response to events. Events can be triggered by user action, by messages from the system or other applications. The sequence of these events determines the sequence in which the code executes each time program runs.

Our code can also trigger events during execution, or it is important to understand to the event driven model.

INTERACTIVE DEVELOPMENT

The traditional application development process can be broken into three steps.

Which are as follows:-

1 Writing2 Compiling3 Testing the code

unlike traditional language, VB uses an interactive approach. With most languages, if we make a mistake the error is caught by the compiler when we start compiling our application. We must then find and fix the errors and then start the compile cycle again, repeating the process for each error. VB interprets our code as we enter it, catching and highlighting the errors. VB also compiles the code as we enter. When we are ready to execute the code there is no delay in compiling.

ELEMENTS OF IDE

The working environment in VB is referred to as the IDE (Integrated Development Environment) because it integrates many functions such as design, coding, editing, compiling, and debugging the

Page 12: Ado Visual Basic

error and immediate windows for different purposes within a single environment.

FORMS AND CONTROLS

The first step to creating an application using VB is to create the interface i.e. the visual part of the application that the user interacts with forms and controls are the basic building block used to create the interface.

1 FORMS :-Forms are objects that process properties that define their

appearance, methods that define their behavior, and events which define their interaction with the user. By setting the properties of the form and writing VB code to respond to its events we can customize the objects to meet the requirements of our application.

2 CONTROLS :- Controls are objects that are contained within form objects.

Each type of control has it’s own properties, methods and events that make it suitable for a particular purpose. Some of these controls we use in our application are best suited for entering or displaying text. Other controls let us access other applications and process data as if the remote application was part of our code.

PROJECT LIMATIONS

Single project can contain up to 32,000 identifiers which include forms, controls, modules, variables, constraints, procedures, functions and objects. Variables name no longer than 255 characters and the names of forms, controls, modules and classes cannot be longer than 40 characters. The amount of code that can be loaded into a form is limited to 65,534 lines. A single line code can consist of 1023 bytes.

Page 13: Ado Visual Basic

ADO Data ControlThe ADO Data control uses Microsoft ActiveX Data Objects (ADO) to quickly create connections between data-bound controls and data providers. Data-bound controls are any controls that feature a DataSource property. Data providers can be any source written to the OLE DB specification. You can also easily create your own data provider using Visual Basic's class module.Although you can use the ActiveX Data Objects directly in your applications, the ADO Data control has the advantage of being a graphic control (with Back and Forward buttons) and an easy-to-use interface that allows you to create database applications with a minimum of code.

Figure 7.4   The ADO Data Control

Several of the controls found in Visual Basic's Toolbox can be data-bound, including the CheckBox, ComboBox, Image, Label, ListBox, PictureBox, and TextBox controls. Additionally, Visual Basic includes several data-bound ActiveX controls such as the DataGrid, DataCombo, Chart, and DataList controls. You can also create your own data-bound ActiveX controls, or purchase controls from other vendors.Previous versions of Visual Basic featured the intrinsic Data control and the Remote Data control (RDC) for data access. Both controls are still included with Visual Basic for backward compatibility. However, because of the flexibility of ADO, it's recommended that new database applications be created using the ADO Data Control.For More Information   A complete list of data-bound controls can be found in "Controls That Bind to the ADO Data Control." To find out how to use the intrinsic Data control or the Remote Data control, see "Using the Data Control" or "Using the Remote Data Control." For details about creating a data provider, see "Creating Data-Aware Classes."

Possible Uses

Connect to a local or remote database.

Page 14: Ado Visual Basic

Open a specified database table or define a set of records based on a Structured Query Language (SQL) query or stored procedure or view of the tables in that database.

Pass data field values to data-bound controls, where you can display or change the values.

Add new records or update a database based on any changes you make to data displayed in the bound controls.

To create a client, or front-end database application, add the ADO Data control to your forms just as you would any other Visual Basic control. You can have as many ADO Data controls on your form as you need. Be aware, however, that the control is a comparatively "expensive" method of creating connections, using at least two connections for the first control, and one more for each subsequent control.

Creating a Front-end Database Application with Minimal CodeIt's possible to create a database application using a minimum of code by setting a few properties at design time. If you are using an OLE DB data source, the Microsoft Data Link Name (.UDL) must be created on your machine. See "Creating the Northwind OLE DB Data Link" for a step-by-step example.To create a simple front-end database application

1. Draw an ADO Data Control on a form. (The icon's ToolTip is "ADODC.")

If the control is not available in the Toolbox, press CTRL+T to display the Components dialog box. In theComponents dialog, click Microsoft ADO Data Control.

2. On the Toolbox, click the ADO Data Control to select it. Then press F4 to display the Properties window.

3. In the Properties window, click ConnectionString to display the ConnectionString dialog box.

4. If you have created a Microsoft Data Link file (.UDL), select Use OLE DB File and click Browse to find the file on the computer. If you use a DSN, click Use ODBC Data Source Name and select a DSN from the box, or click New to create one. If you wish to use create a connection string, select Use ConnectionString, and then click Build, and use the Data Link Properties dialog box to create a connection string. After creating the connection string, click OK. The ConnectionString property will be filled with a string like:

5. driver={SQL Server};server=bigsmile;uid=sa;pwd=pwd;database=pubs

6. In the Properties window, set the RecordSource property to a SQL statement. For example,

7. SELECT * FROM Titles WHERE AuthorID = 72

Page 15: Ado Visual Basic

You should always include a WHERE clause when accessing a table. Failing to do so will lock the entire table, which would be a major hindrance to other users.

8. Draw a TextBox control on the form to display the database information.

9. In the Properties window, set the DataSource property for Text1 to the name of the ADO Data control (ADODC1). This binds the text box to the ADO Data control.

10.In the Properties window, click DataField and a list of available fields will drop down. Click the name of the field you want to display.

11.Repeat steps 6, 7, and 8 for each additional field you want to access. 12.Press F5 to run the application. You can use the four arrow buttons on

the ADO Data control to move to the beginning of the data, to the end of the data, or from record to record through the data.

Setting the ConnectionString, Source, DataSource, and DataField ProgrammaticallyThe code below shows how to set these four properties programmatically. Note that setting the DataSource property requires the Set statement.Private Sub Form_Load() With ADODC1 .ConnectionString = "driver={SQL Server};" & _ "server=bigsmile;uid=sa;pwd=pwd;database=pubs" .RecordSource = "Select * From Titles Where AuthorID = 7" End With Set Text1.DataSource = ADODC1 Text1.DataField = "Title"End Sub

ADO Data Control EventsThe ADO Data control features several events that you can program. The table below shows the events and when they occur; however the table is not meant to be a complete list all of the conditions when the events occur. For complete information, see the reference topic for the individual event.

Event Occurs

WillMove On Recordset.Open, Recordset.MoveNext, Recordset.Move, Recordset.MoveLast, Recordset.MoveFirst, Recordset.MovePrevious, Recordset.Bookmark, Recordset.AddNew, Recordset.Delete,

Page 16: Ado Visual Basic

Recordset.Requery, Recordset.Resync

MoveComplete After WillMove

WillChangeField Before the Value property changes

FieldChangeComplete After WillChangeField

WillChangeRecord On Recordset.Update, Recordset.Delete, Recordset.CancelUpdate, Recordset.UpdateBatch, Recordset.CancelBatch

RecordChangeComplete After WillChangeRecord

WillChangeRecordset On Recordset.Requery, Recordset.Resync, Recordset.Close, Recordset.Open, Recordset.Filter

RecordsetChangeComplete After WillChangeRecordset

InfoMessage When the data provider returns a result

To develop a database application with Visual Basic

1. Start Visual Basic, choosing a Standard Executable project.

2. Add the Microsoft ADO Data Control 6.0 to your tool palette:

o From the Project menu, choose Components.

o Select the Microsoft ADO Data Control 6.0 component from the list.

Page 17: Ado Visual Basic

o Click OK to add the control to the Toolbox palette.

3. Add the ADO Data Control to the form, as follows:

o From the View menu, choose Toolbox.

o Click the Adodc icon in the Toolbox palette.

o Draw a rectangle on the design form.

4. Configure the ADO Data Control:

Property Value

CommandType 2 - adCmdTable

ConnectionString Provider=SAOLEDB;DSN=SQL Anywhere 10 Demo

CursorLocation 2 - adUseServer

CursorType 2 - adOpenDynamic

RecordSource Employees

Page 18: Ado Visual Basic

5. The ConnectionString uses the SQL Anywhere OLE DB Provider (SAOLEDB) to connect to the "SQL Anywhere 10 Demo" data source. The cursor settings take advantage of SQL Anywhere server-side cursors rather than using client-side cursors.

6. Add two text boxes to the form, as follows:

o Click the TextBox icon in the Toolbox palette.

o Draw a rectangle on the design form just above the Adodc1 control as shown in the diagram below.

o Draw a second rectangle on the design form to the right of the first TextBox as shown in the diagram.

7. Bind the text boxes to the ADO Data Control:

o Set the DataSource property for each to be Adodc1.

o Set the DataField property for the left-hand text box to GivenName, which is the column holding the employee's first name.

o Set the DataField property for the right-hand text box to Surname, which is the column holding the employee's last name.

8. Save the project.

9. Run the sample:

o Choose Run > Start to run the application.

The application connects to the SQL Anywhere sample database and puts the name of the first employee in the text boxes, as follows:

o You can use the buttons on the ADO Data Control to scroll through the rows of the result set.

You have now created a simple Visual Basic application that works with ADO and the SQL Anywhere OLEDB provider.

Page 19: Ado Visual Basic

HARDWAREHARDWARE&&

SOFTWARESOFTWARE REQUIREMENTS REQUIREMENTS

Page 20: Ado Visual Basic

SYSTEM REQUIREMENT

In order to install the software your system must the following specification

1 Hardware Requirement:-

Processor : Celorn processor 2.4 or Pentium III or higher

RAM : 128 MB RAM

HD Capacity : 2 G B HD or more Scanner : Should be of good quality

Printer : Inkjet B/W or color

2 Software Requirement: -

Operating System: Windows 98 or higher version Packages : Visual Basic 6.0, Oracle

Page 21: Ado Visual Basic

Conclusion

Now ,as the user /reader has under gone through the listing AND other accessories details of the project work ,so we feel that the user must have become well acquainted with the aim AND feed back of this work. We wish that the acquaintance of the user with this work revals a positive response AND he/she finds this effort of ours in their good thoughts. Of course, at the beginning ,project appeared very small,but when we actually started the work , we encounterd its depth. This project work coverd every aspect of the customer management. The experience of our guide helped us a lot in this regard. This project gives us complete satisfaction.Thanks a million for going through our work ,because your viewing AND satisfaction is the reward for our work in developing this project to its present shape.

Hope you rewind this…. Thanks!

Page 22: Ado Visual Basic

BIBLIOGRAPHY

Title Author

1.Mastering visual BPB Publication by basic 6.0- E.Petroutsos. 2.Visual basic 6 in BPB Publication by record time steve brown.

3. Visual basic 6 devel- BPB Publication by oper’s handbook Petroutsos .