0% found this document useful (0 votes)
107 views49 pages

Iii Cse

The document discusses various SQL commands and concepts including: 1. Creating, altering, dropping, and truncating tables using commands like CREATE TABLE, ALTER TABLE, DROP TABLE, and TRUNCATE TABLE. 2. Creating views using the CREATE VIEW command and updating views. 3. Creating different types of triggers that fire before or after insert, update, or delete operations on tables. 4. Writing PL/SQL programs including functions, procedures, and use of embedded SQL. 5. Designing databases using normalization to break tables into first normal form and second normal form.

Uploaded by

api-3830748
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views49 pages

Iii Cse

The document discusses various SQL commands and concepts including: 1. Creating, altering, dropping, and truncating tables using commands like CREATE TABLE, ALTER TABLE, DROP TABLE, and TRUNCATE TABLE. 2. Creating views using the CREATE VIEW command and updating views. 3. Creating different types of triggers that fire before or after insert, update, or delete operations on tables. 4. Writing PL/SQL programs including functions, procedures, and use of embedded SQL. 5. Designing databases using normalization to break tables into first normal form and second normal form.

Uploaded by

api-3830748
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 49

DDL COMMANDS

1) TO CREATE TABLE:
SQL>CREATE TABLE STUDENT (REGNO NUMBER(10),NAME
VARHCAR2(30),YEARS VARCHAR2(8)DEPT VARCHAR2(18), PRIMARY
KEY(REGNO));

Table Created

2) TO VIEW STRUCTURE OF TABLE:

SQL> DESC STUDENT;

Name Null? Type


----------------------------------------------------------------------------
REGNO NOT NULL NUMBER(10)
NAME VARCHAR2(30)
YEARS VARCHAR2(8)
DEPT VARHCAR2(18)

SQL> CREATE TABLE STUD_TRAINING (REGNO


NUMBER(10),COURSECODE NUMBER(10),DURATION
VHARCHAR2(15),COST NUMBER(10),FOREIGN
KEY(REGNO,COURSECODE) REFERENCES STUDENT ON DELETE
CASCADE. PRIMARY KEY REGNO,COURSECODE));

Table Created.

SQL> DESC STUD_TRAINING;


Name Null? Type
----------------------------------------------------------------------------
REGNO NOTNULL NUMBER(10)
COURSECODE NOTNULL NUMBER(10)
DURATION VARCHAR2( 20)
COST NUMBER(10)

3) TO ALTER TABLE :
SQL> ALTER TABLE STUD_TRAINING MODIFY(DURATION
VARCHAR2( 20) NOT NULL, COST NUMBER(10) NOT NULL);
Table Created

4) TO DROP TABLE:

SQL> DROP TABLE STUD;

Table Dropped

5) TO TRUNCATE TABLE:

SQL> TRUNCATE TABLE STUDENT;

Table Truncated.
DML COMMANDS

SQL> SELECT REG_NO,M1,M2,M3,M4,M5, (M1+M2+M3+M4+M5)


"TOTAL MARKS",(M1+M2+M3+M4+M5)/5
2 "AVEARGE" FROM MARK1 WHERE REG_NO='S208794';

REG_NO M1 M2 M3 M4 M5
TOTAL MARKS AVEARGE
-----------------------------------------------------------------------------
--------- ---------
S208794 89 90 98 98 90
465 93

SQL> SELECT ((10*10-5*5)/(10-5)) FROM DUAL;

((10*10-5*5)/(10-5))
--------------------
15

SQL> SELECT REPLACE('MARIA','A','V') "REPLACE" FROM DUAL;


REPLA
---------
MVRIV

SQL>SELECT ROLLNO,NAME,CLASS,COUNT(TOTAL) FROM STUDENT


GROUP BY ROLLNO,NAME,CLASS HAVING NAME='M.PALANIAPPAN';

ROLLNO NAME CLASS COUNT(TOTAL)


---------- ------------------------- --------------------
---------------
S108612 M.PALANIAPPAN DISTINCTION 1
CREATING VIEWS

1) TO CREATE VIEW:

SQL> CREATE VIEW VANME1 AS SELECT * FROM STUDENT;

View Created

SQL> DESC VANME1;

Name Null? Type


------------------------------------------------------------------------
NAME VARCHAR2( 15)
REGNO NUMBER(2)
YEAR NUMBER( 8)
DEPT VARCHAR2( 8)

2) TO CREATING VIEWS USING WHERE CLAUSE:

SQL> CREATE VIEW VNAME2;

SQL>CREATE VIEW VNAME2 AS SELECT DEPT,NAME FROM


STUDENT WHERE(NAME=’RAMESH’);

View Created

SQL> SELECT * FROM VNAME2;


DEPT NAME
-----------------------------------------------
EEE RANI

3) UPDATION:
SQL>UPDATE VNAME1 SET NAME=’RAM’ WHERE(NAME=’RANI’);
1 Row Updated.

SSQL> SELECT * FROM VNAME1;

NAME REGNO YEAR DEPT


------------------------------------------------------------------------
JOHN 12 3 EEE

4)CREATE VIEW USING READ ONLY:

SQL>CREATE VIEW VNAME3 AS SELECT * FROM STUDENT WITH


READ ONLY;

View Created

SQL> UPDATE VNAME3 SETNAME=’RAMESH’ WHERE


(NAME=’RAM’);

VIRTUAL COLUMN NOT ALLOWED HERE.


TRIGGERS

1. BEFORE INSERT TRIGGER:

SQL> CREATE OR REPLACE TRIGGER BEFORE _INSERT BEFORE


INSERT ON STUDENT
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE (“This trigger first before Insert
the record”);
4 END;
5 /

Trigger Created.

SQL>INSERT INTO STUDENT VALUES (2,’RAMESH’, ’CSC’


,TO_DATE(’12-11-98’,’DD-MM-YY’););

This trigger fires before insert the record.

2. BEFORE INSERT EACH ROW TRIGGER:

SQL> CREATE OR REPLACE TRIGGER TNAME BEFORE INSERT ON


STUDENT FOR EACH ROW;
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE (‘This trigger fires before insert each
record’);
4 END;
5 /

SQL>INSERT INTO STUDENT VALUES(33,”RAMESH’,’CSE’,21


TO_DATE(’10-10-98’,’DD-MM-YY’));

This trigger fires before insert each record.

3. AFTER INSERT TRIGGER:

SQL> CREATE OR REPLACE TRIGGER TNAME AFTER INSERT ON


STUDENT;
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE (‘This trigger fires after insert
the record’);
4. END;
5. /

SQL>INSERT INTO STUDENT VALUES(33,”RAMESH’,’CSE’,21


TO_DATE(’10-10-98’,’DD-MM-YY’));

This trigger fires after insert the record.

6. AFTER INSERT EACH ROW TRIGGER:


SQL> CREATE OR REPLACE TRIGGER TNAME BEFORE INSERT ON
STUDENT;
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE (‘This trigger fires before insert
the record’);
4 END;
5 /

Trigger Created.

SQL>INSERT INTO STUDENT VALUES(33,”RAMESH’,’CSE’,21


TO_DATE(’10-10-98’,’DD-MM-YY’));

This trigger fires before insert the record.

7. BEFORE UPDATE TRIGGER:

SQL> CREATE OR REPLACE TRIGGER TNAME BEFORE UPDATE ON


STUDENT;
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE (‘This trigger fires before
update on each record’);
4 END;
5 /

Trigger Created.

SQL>INSERT INTO STUDENT VALUES(33,”RAMESH’,’CSE’,21


TO_DATE(’10-10-98’,’DD-MM-YY’));

This trigger fires before update on each record.

8. BEFORE EACH ROW UPDATE TRIGGER.

SQL> CREATE OR REPLACE TRIGGER TNAME BEFORE UPDATE ON


STUDENT FOR EACH ROW
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE(This trigger fires before each record
is updated’);
4 END;
5 /

Trigger Created.

SQL>UPDATE STUDENT SET REGNO=3 WHERE NAME=’RAMESH’;

This trigger fires before each record is updated.

9. AFTER UPDATE TRIGGER.

SQL> CREATE OR REPLACE TRIGGER TNAME AFTER UPDATE ON


STUDENT FOR EACH ROW
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE(This trigger fires after each
record is updated’);
4 END;
5 /

Trigger Created.

SQL>UPDATE STUDENT SET REGNO=3 WHERE NAME =


’RAMESH’;

This trigger fires after each record is updated.

10. EACH ROW UPDATE TRIGGER.


SQL> CREATE OR REPLACE TRIGGER TNAME BEFORE UPDATE ON
STUDENT FOR EACH ROW
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE(This trigger fires before each
record is updated’);
4 END;
5 /

Trigger Created.

SQL>UPDATE STUDENT SET REGNO=3 WHERE NAME=’RAMESH’;

This trigger fires before each record is updated.

11. AFTER UPDATE TRIGGER.


SQL> CREATE OR REPLACE TRIGGER TNAME AFTER UPDATE ON
STUDENT FOR EACH ROW
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE(This trigger fires after each
record is updated’);
4 END;
5 /

Trigger Created.

SQL>UPDATE STUDENT SET REGNO=3 WHERE NAME =’RAMESH’;

This trigger fires after each record is updated.

12. BEFORE DELETE TRIGGER.

SQL> CREATE OR REPLACE TRIGGER TNAME BEFORE DELETE ON


STUDENT
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE(This trigger fires before delete
on each record ’);
4 END;
13. /
Trigger Created.

SQL>DELETE FROM STUDENT WHERE NAME=’RAMESH’ WHERE


REGNO=3;

This trigger fires before delete on each record

14. BEFORE EACH ROW DELETE TRIGGER:


SQL> CREATE OR REPLACE TRIGGER TNAME BEFORE DELETE ON
STUDENT FOR EACH ROW
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE(This trigger fires before each
record is deleted’);
4 END;
5 /

Trigger Created.

SQL>DELETE FROM STUDENT WHERE NAME=’RAMESH’;

This trigger fires before each record is deleted.

15. AFTER DELETE TRIGGER:

SQL>CREATE OR REPLACE TRIGGER TNAME AFTER DELETE ON


STUDENT FOR EACH ROW
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE(This trigger fires after each
record is deleted’);
4 END;
5 /

Trigger Created.

SQL>DELETE FROM STUDENT WHERE NAME=’RAMESH’;

This trigger fires after each record is deleted.

16. AFTER EACH ROW DELETE TRIGGER:

SQL>CREATE OR REPLACE TRIGGER TNAME AFTER DELETE ON


STUDENT FOR EACH ROW
2 BEGIN
3 DBMS_OUTPUT.PUT_LINE(This trigger fires after each
record is deleted’);
4 END;
5 /

Trigger Created.

SQL>DELETE FROM STUDENT WHERE NAME=’RAMESH’;

This trigger fires after each record is deleted.


PROGRAM FOR PROCEDURE:

SQL> GET HELLO


2 DECLARE
3 FUNCTION HELLO RETURN;
4 BEGIN
5 RETURN ‘WORLD’;
6 EXIT;
7 BEGIN
8 DBMS_OUTPUT.PUT_LINE(Hello);
9 END;
10 /

SQL> SET SERVEROUTPUT ON

SQL> /

PL/SQL Procedure successfully completed.


PROGRAM FOR FUNCTION

SQL>GET PAULS

2 CREATE OR REPLACE FUNCTION


3 PAULS(X VARCHAR2) RETURN VARCHAR2 AS
4 BEGIN
5 RETURN X|| ‘IS THE PARAMETER’;
6 END;
7 /

SQL> /

Function Created.
EMBEDDED SQL
Definition:

PL/SQL functions can execute any DML statement that can be


executed in SQL*Plus

FUNCTION Grant_Vacation (nAddDays IN number,


nFacultyMember IN number)

RETURN number

IS

BEGIN

SELECT base_Vacation INTO nvacationDays FROM FACULTY


WHERE faculty_id = nFacultyMemebr;
RETURN (nVacationDays+ nAddDays);

END;
DATABASE DESIGN USING E-R MODEL AND
NORMALIZATION

Ist Normal Form (1NF)

WORKER TABLE

NAME NOT NULL? VARCHAR2(25)


AGE NUMBER(3)
HOUSE VARCHAR2(25)
MANAGER_NAME VARCHAR2(26)

SKILL TABLE

NAME NOT NULL? VARCHAR2(25)


SKILL NOT NULL? VARCHAR2(10)
DESCRIPTION VARCHAR2(30)
WORK_PERFORMANCE VARCHAR2( 20)

2nd NORMAL FORM (2NF)

WORKER TABLE

NAME NOT NULL? VARCHAR2(25)


AGE NUMBER(3)
AREA VARCHAR2( 25)
HOUSE VARCHAR2(25)
MANAGER_NAME VARCHAR2(26)
ADDRESS VARCHAR2(30)

SKILL TABLE

SKILL NOT NULL? VARCHAR2(10)


DESCRIPTION VARCHAR2(30)

WORKERSKILL TABLE

NAME VARCHAR2(25)
SKILL VARCHAR2(10)
WORK_PERFORMANCE VARCHAR2(26)

3rd NORMAL FORM(3NF)

WORKER TABLE :

NAME VARCHAR2(25)
AGE NUMBER(3)
AREA VARCHAR2( 25)

WORKERSKILL TABLE

NAME VARCHAR2(25)
SKILL VARCHAR2(10)
WORK_PERFORMANCE VARCHAR2(26)

SKILL TABLE

SKILL NOT NULL? VARCHAR2(10)


DESCRIPTION VARCHAR2(30)
AREA TABLE :

HOUSE VARCHAR2( 26)


FULL_ADDRESS VARCHAR2( 30)
MANAGER_NAME VARCHAR2( 25)
ADDRESS VARCHAR2( 30)

PAY ROLL SYSTEM PROJECT CODE

MDIPayRoll Code:

Private Sub mnuDeletion_Click()


frmdeletion.Show
End Sub

Private Sub mnuExit_Click()


End
End Sub

Private Sub mnuInsertion_Click()


frmPayRoll.Show
End Sub

Private Sub mnuModify_Click()


frmModification.Show
End Sub

Private Sub mnuReport_Click()


DataReport1.Show
End Sub

Private Sub mnuView_Click()


frmView.Show
End Sub
FrmDeletion Code:

Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdOk_Click()


RS.Find "emp_id='" & Text1.Text & "'"
If RS.EOF Then
MsgBox "Record Not Found"
Else
RS.Delete
MsgBox "Record is Deleted"
End If
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from payroll", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub

FrmPayRoll Code:
Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdOk_Click()


RS.AddNew
RS(0) = Text1.Text
RS(1) = Text2.Text
RS(2) = Text3.Text
RS(3) = Text4.Text
RS(4) = Text5.Text
RS(5) = Text6.Text
RS(6) = Text7.Text
RS(7) = Text8.Text
RS(8) = Text9.Text
RS(9) = Text10.Text
RS.Update
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from payroll", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub

Private Sub Text4_LostFocus()


If Text4 > 10000 Then
Text5 = Val(Text4) * 0.2
Text6 = Val(Text4) * 0.2
Text7 = Val(Text4) * 0.05
Text8 = Val(Text4) * 0.1
Text9 = (Val(Text4) + Val(Text5) + Val(Text6))
Text10 = Val(Text9) - (Val(Text7) + Val(Text8))
Else
Text5 = Val(Text4) * 0.1
Text6 = Val(Text4) * 0.1
Text7 = Val(Text4) * 0.02
Text8 = Val(Text4) * 0.05
Text9 = (Val(Text4) + Val(Text5) + Val(Text6))
Text10 = Val(Text9) - (Val(Text7) + Val(Text8))
End If
End Sub

FrmModification Code:

Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdOk_Click()


RS(0) = Text1.Text
RS(1) = Text2.Text
RS(2) = Text3.Text
RS(3) = Text4.Text
RS(4) = Text5.Text
RS(5) = Text6.Text
RS(6) = Text7.Text
RS(7) = Text8.Text
RS(8) = Text9.Text
RS(9) = Text10.Text
RS.Update
MsgBox "Record is Modified"
Clear
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from payroll", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyCode = 13 Then
RS.Find "emp_id='" & Text1.Text & "'"
If Not RS.EOF Then
Text1.Text = RS(0)
Text2.Text = RS(1)
Text3.Text = RS(2)
Text4.Text = RS(3)
Text5.Text = RS(4)
Text6.Text = RS(5)
Text7.Text = RS(6)
Text8.Text = RS(7)
Text9.Text = RS(8)
Text10.Text = RS(9)
Else
MsgBox "Record Not Found"
Text1 = ""
End If
End If
End Sub

Public Sub Clear()


Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
End Sub

Private Sub Text4_LostFocus()


If Text4 > 10000 Then
Text5 = Val(Text4) * 0.2
Text6 = Val(Text4) * 0.2
Text7 = Val(Text4) * 0.05
Text8 = Val(Text4) * 0.1
Text9 = (Val(Text4) + Val(Text5) + Val(Text6))
Text10 = Val(Text9) - (Val(Text7) + Val(Text8))
Else
Text5 = Val(Text4) * 0.1
Text6 = Val(Text4) * 0.1
Text7 = Val(Text4) * 0.02
Text8 = Val(Text4) * 0.05
Text9 = (Val(Text4) + Val(Text5) + Val(Text6))
Text10 = Val(Text9) - (Val(Text7) + Val(Text8))
End If
End Sub
FrmView Code:

Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdLast_Click()


RS.MoveLast
Text1.Text = RS(0)
Text2.Text = RS(1)
Text3.Text = RS(2)
Text4.Text = RS(3)
Text5.Text = RS(4)
Text6.Text = RS(5)
Text7.Text = RS(6)
Text8.Text = RS(7)
Text9.Text = RS(8)
Text10.Text = RS(9)
End Sub

Private Sub cmdNext_Click()


RS.MoveNext
If Not RS.EOF Then
Text1.Text = RS(0)
Text2.Text = RS(1)
Text3.Text = RS(2)
Text4.Text = RS(3)
Text5.Text = RS(4)
Text6.Text = RS(5)
Text7.Text = RS(6)
Text8.Text = RS(7)
Text9.Text = RS(8)
Text10.Text = RS(9)
Else
MsgBox "You are in Last Record"
End If
End Sub

Private Sub cmdPrevious_Click()


RS.MovePrevious
If Not RS.BOF Then
Text1.Text = RS(0)
Text2.Text = RS(1)
Text3.Text = RS(2)
Text4.Text = RS(3)
Text5.Text = RS(4)
Text6.Text = RS(5)
Text7.Text = RS(6)
Text8.Text = RS(7)
Text9.Text = RS(8)
Text10.Text = RS(9)
Else
MsgBox "You are in First Record"
End If
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from payroll", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub
Private Sub cmdFirst_Click()
RS.MoveFirst
Text1.Text = RS(0)
Text2.Text = RS(1)
Text3.Text = RS(2)
Text4.Text = RS(3)
Text5.Text = RS(4)
Text6.Text = RS(5)
Text7.Text = RS(6)
Text8.Text = RS(7)
Text9.Text = RS(8)
Text10.Text = RS(9)
End Sub

SAVING BANK ACCOUNT FOR BANKING PROJECT CODE

MDIBank Code:

Private Sub mnuDelete_Click()


frmDeleteBank.Show
End Sub

Private Sub mnuDeposit_Click()


frmDeposit.Show
End Sub

Private Sub mnuExit_Click()


End
End Sub

Private Sub mnuInsert_Click()


frmBankMaster.Show
End Sub

Private Sub mnuModify_Click()


frmModifyBank.Show
End Sub

Private Sub mnuReport_Click()


DataReport1.Show
End Sub

Private Sub mnuView_Click()


frmViewBank.Show
End Sub

Private Sub mnuWithdraw_Click()


frmWithDraw.Show
End Sub

FrmBankMaster Code:
Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset
Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdOk_Click()


RS.AddNew
RS(0) = Text1.Text
RS(1) = Text2.Text
RS(2) = Text3.Text
RS(3) = Text4.Text
RS.Update
MsgBox " New Account is Opened"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from bank1", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub

FrmDeleteBank Code:
Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdOk_Click()


RS.Find "acc_no='" & Text1.Text & "'"
If RS.EOF Then
MsgBox "Invalid Account Number"
Else
RS.Delete
MsgBox "Account Number is Deleted"
Text1 = ""
End If
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from bank1", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub

FrmModifyBank Code:
Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdOk_Click()


RS(0) = Text1.Text
RS(1) = Text2.Text
RS(2) = Text3.Text
RS(3) = Text4.Text
RS.Update
MsgBox "Account is Modified"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from bank1", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
RS.Find "acc_no='" & Text1 & "'"
If RS.EOF Then
MsgBox "Invalid Account Number"
Else
Text1 = RS(0)
Text2 = RS(1)
Text3 = RS(2)
Text4 = RS(3)
End If
End If
End Sub

FrmViewBank Code:
Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdLast_Click()


RS.MoveLast
Text1.Text = RS(0)
Text2.Text = RS(1)
Text3.Text = RS(2)
Text4.Text = RS(3)
End Sub

Private Sub cmdNext_Click()


RS.MoveNext
If Not RS.EOF Then
Text1.Text = RS(0)
Text2.Text = RS(1)
Text3.Text = RS(2)
Text4.Text = RS(3)
Else
MsgBox "You are in Last Record"
End If
End Sub

Private Sub cmdPrevious_Click()


RS.MovePrevious
If Not RS.BOF Then
Text1.Text = RS(0)
Text2.Text = RS(1)
Text3.Text = RS(2)
Text4.Text = RS(3)
Else
MsgBox "You are in First Record"
End If
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from bank1", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub
Private Sub cmdFirst_Click()
RS.MoveFirst
Text1.Text = RS(0)
Text2.Text = RS(1)
Text3.Text = RS(2)
Text4.Text = RS(3)
End Sub

FrmDeposit Code:

Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset
Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdOk_Click()


RS.Fields("acc_no") = Text1.Text
RS.Fields("name") = Text2.Text
RS.Fields("balance") = Text3.Text
RS.Update
MsgBox "Deposit Amount is Updated"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from bank1", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
RS.Find "acc_no='" & Text1 & "'"
If RS.EOF Then
MsgBox "Invalid Account Number"
Else
Text1 = RS.Fields("acc_no")
Text2 = RS.Fields("name")
Text3 = RS.Fields("balance")
End If
End If
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
Text3 = Val(Text3) + Val(Text4)
End If
End Sub

FrmWithDraw Code:

Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdOk_Click()


RS.Fields("acc_no") = Text1.Text
RS.Fields("name") = Text2.Text
RS.Fields("balance") = Text3.Text
RS.Update
MsgBox "WithDraw Amount is Updated"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from bank1", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
RS.Find "acc_no='" & Text1 & "'"
If RS.EOF Then
MsgBox "Invalid Account Number"
Else
Text1 = RS.Fields("acc_no")
Text2 = RS.Fields("name")
Text3 = RS.Fields("balance")
End If
End If
End Sub

Private Sub Text4_Change()


cmdOk.Enabled = True
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If (Val(Text3) - 200) >= Val(Text4) Then
Text3 = Val(Text3) - Val(Text4)
Else
MsgBox "No Balance", vbCritical
cmdOk.Enabled = False
End If
End If
End Sub

LIBRARY INFORMATION SYSTEM PROJECT CODE

MDILibraray Code:

Private Sub mnuDeletion_Click()


frmDeleteLIS.Show
End Sub

Private Sub mnuExit_Click()


End
End Sub

Private Sub mnuInserion_Click()


frmLIS.Show
End Sub

Private Sub mnuModification_Click()


frmModifyLIS.Show
End Sub

Private Sub mnuReport_Click()


libRpt.Show
End Sub

Private Sub mnuView_Click()


frmViewLIS.Show
End Sub

FrmLIS Code:

Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdOk_Click()


RS.Close
RS.Open "select * from library", DB, adOpenDynamic,
adLockOptimistic
RS.Find "account_code='" & Text1 & "'"
If RS.EOF Then
RS.AddNew
RS(0) = Text1.Text
RS(1) = Text2.Text
RS(2) = Text3.Text
RS(3) = Text4.Text
RS(4) = Text5.Text
RS(5) = Text6.Text
RS(6) = Text7.Text
RS.Update
MsgBox " New Account is Added"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Else
MsgBox "Entry Another Account Code", vbCritical
End If
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from library", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub

Private Sub Text5_LostFocus()


Dim d1, d2 As Date
d1 = Date
Text6 = Format(d1, "dd-MMM-yyyy")
d2 = DateAdd("d", 15, d1)
Text7 = Format(d2, "dd-MMM-yyyy")
End Sub
FrmModifyLIS Code:

Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdOk_Click()


RS(0) = Text1.Text
RS(1) = Text2.Text
RS(2) = Text3.Text
RS(3) = Text4.Text
RS(4) = Text5.Text
RS(5) = Text6.Text
RS(6) = Text7.Text
RS.Update
MsgBox "Account is Modified"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from library", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


RS.Close
RS.Open "select * from library", DB, adOpenDynamic,
adLockOptimistic
RS.Find "account_code='" & Text1 & "'"
If RS.EOF Then
MsgBox "Account Number Not Found"
Else
Text1 = RS(0)
Text2 = RS(1)
Text3 = RS(2)
Text4 = RS(3)
Text5 = RS(4)
Text6 = Format(RS(5), "dd-MMM-yyyy")
Text7 = Format(RS(6), "dd-MMM-yyyy")
End If
End Sub

Private Sub Text5_LostFocus()


Dim d1, d2 As Date
d1 = Date
Text6 = Format(d1, "dd-MMM-yyyy")
d2 = DateAdd("d", 15, d1)
Text7 = Format(d2, "dd-MMM-yyyy")
End Sub

FrmDeleteLibrary Code:
Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset
Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdOk_Click()


Dim Response As Integer
RS.Close
RS.Open "select * from library", DB, adOpenDynamic,
adLockOptimistic
RS.Find "account_code='" & Text1 & "'"

If RS.EOF Then
MsgBox "Account Number Not Found"
Else
Response = MsgBox("Are You Sure?", vbOKCancel,
"DELETION[LIS]")
If Response = vbOK Then
RS.Delete
MsgBox "Account Number is deleted"
Text1 = ""
Else
MsgBox "Account Number is not deleted"
Text1 = ""
End If
End If
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from library", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub
FrmViewLIS Code:
Option Explicit
Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdFirst_Click()


RS.MoveFirst
Text1 = RS(0)
Text2 = RS(1)
Text3 = RS(2)
Text4 = RS(3)
Text5 = RS(4)
Text6 = Format(RS(5), "dd-MMM-yyyy")
Text7 = Format(RS(6), "dd-MMM-yyyy")
End Sub

Private Sub cmdLast_Click()


RS.MoveLast
Text1 = RS(0)
Text2 = RS(1)
Text3 = RS(2)
Text4 = RS(3)
Text5 = RS(4)
Text6 = Format(RS(5), "dd-MMM-yyyy")
Text7 = Format(RS(6), "dd-MMM-yyyy")
End Sub

Private Sub cmdNext_Click()


RS.MoveNext
If Not RS.EOF Then
Text1 = RS(0)
Text2 = RS(1)
Text3 = RS(2)
Text4 = RS(3)
Text5 = RS(4)
Text6 = Format(RS(5), "dd-MMM-yyyy")
Text7 = Format(RS(6), "dd-MMM-yyyy")
Else
MsgBox "You Are in Last Record", vbInformation, "INVENTORY
VIEW"
End If
End Sub

Private Sub cmdPrevious_Click()


RS.MovePrevious
If Not RS.BOF Then
Text1 = RS(0)
Text2 = RS(1)
Text3 = RS(2)
Text4 = RS(3)
Text5 = RS(4)
Text6 = Format(RS(5), "dd-MMM-yyyy")
Text7 = Format(RS(6), "dd-MMM-yyyy")
Else
MsgBox "You Are in First Record", vbInformation, "INVENTORY
VIEW"
End If
End Sub

Private Sub Form_Load()


Set DB = New ADODB.Connection
DB.Open "RAMESH", "scott", "tiger"
Set RS = New ADODB.Recordset
RS.Open "select * from library", DB, adOpenDynamic,
adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)


RS.Close
DB.Close
End Sub
PAYROLL PROCESSING SYSTEM

TABLE STRUCTURE

TABLE NAME : PAYROLL


EMP_CODE NOT NULL ? VARCHAR2(10)
EMP_NAME VARCHAR2(30)
DESIGNATION VARCHAR2(15)
BASIC_PAY NUMBER( 10,2)
HRA NUMBER( 10,2)
DA NUMBER(10,2)
TA NUMBER( 10,2)
INCENTIVES NUMBER( 10,2)
PROVIDENT_FUND NUMBER( 10,2)
LOAN NUMBER( 10,2)
GROSS_SALARY NUMBER( 10,2)
DEDUCTION NUMBER(10,2)
NET_SALARY NUMBER( 10,2)

BANK PROCESSING SYSTEM

TABLE STRUCTURE

TABLE NAME : BANK


ACCOUNT_NO NOT NULL? NUMBER( 12)
CUST_NAME VARCHAR2( 30)
FATHER_NAME VARCHAR2( 30)
SEX VARCHAR2( 6)
ADDRESS_COMM VARCHAR2( 50)
DEPOSIT_AMOUNT NUMBER( 10,2)
WITH_DRAW_AMO NUMBER( 10,2)
BALANCE_AMO NUMBER( 10,2)

LIBRARY INFORMATION SYSTEM

TABLE STRUCTURE

TABLE NAME : LIBRARY


MEMBER_NO NOT NULL? NUMBER( 12)
BOOK_TITLE VARCHAR2( 29)
AUTHOR VARCHAR2( 28)
PUBLIS_NAME VARCHAR2( 29)
ISBN_NO NUMBER( 20)
PRICE NUMBER( 7,2)

TABLE NAME : BOOKS

MEMEBR_NO NOT NULL? NUMBER( 12)


NAME VARCHAR2( 27)
ADDRESS VARCHAR2( 50)
BOOK_ISSUE DATE()
BOOK_RET DATE()
FINE_AMO NUMBER(5,2)

Issued Author
Member_id
Book
ISBN No
Title

Book Borrower Library Information System Book


Memb
er

No. of Books Price


Name

Return Date

Publisher Name
Banking Information System
Deposit
Customer_id
Acc_no
Withdraw

Customer Deposi Account


t

Balance Interest
Name

Address

Payroll Processing System


House Rent
Allowance
Emp_id
TA
Basic Pay

Employee Job Salary

DA
Employee Name

Incentives

Deduction
Bonus

Gross Salary

You might also like