Skip to main content

Oracle and VB 6.0 Connectivity (Part 2)

The first part defined how to establish connectivity between the back end and the front end of the project. Next we will see how to implement triggers.
Oracle
We need to Create the triggers in the oracle.
1) type ed in sql
2) it opens a notepad window
3) type the trigger as in the below example
4) exit the notepad with saving
5)and then type "/"
6) this will show a message as trigger created!
7) It should not show trigger created with compilation errors. If this message is shown check your syntax of trigger.

Example:
create or replace trigger votertrig
after update or delete on voter
for each row
begin
insert into votertemp values(:old.id,:old.name,:old.address,:old.age,:old.gender,:old.dob);
end;

Whenever we perform an update or delete operation the old values get stored into the votertemp table and the changed data gets reflected into the permanent table

Visual Basic 6.0
In VB we do not have to do anything as triggers are automatically fired whenever an update or delete operation takes place. The admin can log in into the oracle and view the modifications including the old as well as new values from the voter and votertemp table.

We have successfully set up triggers in the Oracle Back End and when an user deletes or updates any record through the VB front end application the trigger gets fired. We will see procedures in the next part 3.
Part 3

Comments

  1. we are implementing your coding and they are working perfect. Thank you very much.

    But we want coding for " delete" and "entering next record" in the same way as given for "add" in your blog.
    I sincerely request you to give coding for both urgently as we have exam day after tomorrow.
    we have implemented other coding for both of them but they are not working.Please post your coding.we have to finish this project today only.
    monikagawai.19@gmail.com

    ReplyDelete

Post a Comment

Popular posts from this blog

Oracle and VB 6.0 Connectivity (Part 1)

Here is a basic VB application called voter information system demonstrated which explains the concepts quite clearly. The first step required to establish connectivity is preparing the back end and the front end of the project. These steps are divided into two parts first the back end that is the oracle and front end that is the Visual Basic 6.0. Oracle Firstly we need to set up the database. Create the tables, triggers and procedures and database in the oracle. Create tables: Example: create table voter(id number(5) primary key, name varchar2(25),address varchar2(50),age number(3),gender varchar2(6),dob varchar2(30)); create table votertemp(id number(5) primary key, name varchar2(25),address varchar2(50),age number(3),gender varchar2(6),dob varchar2(30)); (we will be using the next table in the triggers that we will be implementing) Visual Basic 6.0 Develop the VB application as in this example given below. Design the necessary forms for the application. The next part is

Validations in Visual Basic 6.0

This topic will demonstrate how to perform client side validations in Visual Basic 6.0. It will guide you with a step by step procedure. 1) Firstly in the below image suppose you want to accept only integer numbers as id in the textbox next to ID label in the form from the user you can perform client side validations in the following way: These are the ascii codes that i am using for acepting only integer values from user. Back space - 8 0 to 9 Integers - 48 to 57 Delete - 127 This is how the function will look. Private Sub Text2_KeyPress(KeyAscii As Integer) If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 127 Or KeyAscii = 8) Then MsgBox "enter proper value" KeyAscii = 0 End If End Sub Double click on the text box which you want to validate. Next select the event as keypress from top right list box. In this case the name of text box is text1. This is the function for accepting input as integer value only from the user.

Oracle and VB 6.0 Connectivity (Part 3)

Now we will see how to insert values into table a table and to view them. Oracle Initially we had created table in part1. Visual Basic 6.0 Now we wil insert data into the table through visual basic. The code for inserting will be as follows When you double click on add button it will open your code window it will have this code! Private Sub Command1_Click() Dim gen As String If (Option1.Value = True) Then gen = "male" ElseIf (Option2.Value = True) Then gen = "female" End If rsv.Open "insert into voter values(" & Text5.Text & ",'" & Text2.Text & "','" & Text3.Text & "','" & Combo1.Text & "','" & gen & "','" & DTPicker1.Value & "')", conv, adOpenDynamic, adLockOptimistic If (rsv.State = 1) Then rsv.Close End If MsgBox ("Data Entered") End Sub This will add the data entered into