Professional Documents
Culture Documents
1. Introduction to SQL
Address varchar(255),
City varchar(255)
);
3.1 Insert
The INSERT INTO statement is used to insert new records in a table.
SQL INSERT INTO Syntax
It is possible to write the INSERT INTO statement in two forms.
The first form does not specify the column names where the data will be inserted, only their values:
INSERT INTO table_name
VALUES (value1,value2,value3,...);
The second form specifies both the column names and the values to be inserted:
INSERT INTO table_name (column1,column2,column3,...)
VALUES (value1,value2,value3,...);
3.2 Update
The UPDATE statement is used to update existing records in a table.
SQL UPDATE Syntax
UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;
Assume we wish to update the customer "AlfredsFutterkiste" with a new contact person and city.
UPDATE Customers
SET ContactName='Alfred Schmidt', City='Hamburg'
WHERE CustomerName='AlfredsFutterkiste';
3.2.1 Delete
The SQL DELETE Statement
The DELETE statement is used to delete rows in a table.
SQL DELETE Syntax
DELETE FROM table_name
WHERE some_column=some_value;
DELETE Example
Assume we wish to delete the customer "AlfredsFutterkiste" from the "Customers" table.
DELETE FROM Customers
WHERE CustomerName='AlfredsFutterkiste' AND ContactName='Maria Anders';
3.2.2 Select
The SELECT statement is used to select data from a database.
The result is stored in a result table, called the result-set.
SQL SELECT Syntax:
SELECT column_name,column_name
FROM table_name;
also
SELECT * FROM table_name;
DBMS
A data control language (DCL) is a syntax similar to a computer programming language used to control access
to data stored in a database. In particular, it is a component of Structured Query Language (SQL).
The operations for which privileges may be granted to or revoked from a user or role may include CONNECT,
SELECT, INSERT, UPDATE, DELETE, EXECUTE, and USAGE.
In the Oracle database, executing a DCL command issues an implicit commit. Hence you cannot roll back the
command.
4.1 Begin Transaction
4.2 Commit
The COMMIT statement ends the current transaction, making any changes made during that transaction
permanent, and visible to other users.
Commit Syntax:
SQL>commit;
Commit Example:
BEGIN
UPDATE emp_information SET emp_dept='Web Developer'
WHERE emp_name='bhavesh';
DBMS
COMMIT;
END;
4.3 Rollback
The ROLLBACK statement ends the current transaction and undoes any changes made during that transaction.
If you make a mistake, such as deleting the wrong row from a table, a rollback restores the original data. If you
cannot finish a transaction because an exception is raised or a SQL statement fails, a rollback lets you take
corrective action and perhaps start over.
ROLLBACK Syntax:
INSERT INTO table_name VALUES (value1,value2..,values n)
BEGIN TRANSACTION
(-- Some Operations--)
ROLLBACK;
ROLLBACK Example:
INSERT INTO Book_Issue VALUES (12334,HTML5 Reference, Hans Tom,2005)
BEGIN TRANSACTION
UPDATE Book_Issue SET author = Hans Tom
WHERE Book_Id = 12334
ROLLBACK;
DBMS
For Example: REVOKE SELECT ON employee FROM user1;This command will REVOKE a SELECT
privilege on employee table from user1.When you REVOKE SELECT privilege on a table from a user, the user
will not be able to SELECT data from that table anymore. However, if the user has received SELECT privileges
on that table from more than one users, he/she can SELECT from that table until everyone who granted the
permission revokes it. You cannot REVOKE privileges if they were not initially granted by you.
5.5 Locking
Database locks are used to provide concurrency control in order to ensure data consistency and integrity.
Common uses of locks are:
ensure that only one user can modify a record at a time;
ensure that a table cannot be dropped while another user is querying it;
ensure that one user cannot delete a record while another is updating it.
Syntax:
LOCK TABLE tablename IN <lockmode> MODE [NOWAIT]
lockmodes:
EXCLUSIVE
SHARE
ROW EXCLUSIVE
SHARE ROW EXCLUSIVE
If NOWAIT is omitted Oracle will wait until the table is available.
Several tables can be locked with a single command - separate with commas
e.g.LOCK TABLE table1,table2,table3 IN ROW EXCLUSIVE MODE;
DBMS
10
1.1Abstract (Overview)
This project is Entitled as KTM Bike showroom management system
developed using VB.net as a Front End and Mysql as a Back End. This project is ideal for dealers
or resellers of any size. The Bike showroom control panel can be access anywhere in any time.
Bike showroom management system describes the complete process of selling a Bike and also
the Staff management.
KTM Bike Showroom Management system will provide the
showroom managing in much easier fashion. The modules are they can manage the Bike booking
system , services stock information in the showroom and also the staff details . The Bike booking
system will be done by the admin and managing also they will set the delivery date of the bike
and the order will complete in the current date . And In the Service module also admin will take
care of that admin will assign a staff for a bike in the service managing. In the showroom
management the admin will take care of the bike stock details and the Adding Updating Deleting
of the bikes.
The purpose of this application is to design a system to maintain the information related to
a Bike Showroom.
The objective of this application is to design a system to maintain the information related
to a Bike Showroom. The purpose is to maintain a centralized repository of information
about all activities regarding a showroom.
It is User Friendly and Secure the Data.
Can easily make the daily reports.
It will simplifies the task and reduce the paper work.
During implementation every user will be given appropriate training to suit their specific
needs.
10
11
Faster process
User Friendly
Better management
Save a lot of manpower
Can easily make the daily reports
Elimination of Paper work,
High reliability and security.
Fast and economical.
DBMS
11
12
Hardware:
Processor
Ram
256 MB or more
Cache
512 KB
Hard disk
Software:
Operating system
Visual Basic.NET
Backend Software
Mysql
4. SYSTEM DESIGN
Modules Design
Login Module
Booking Module
Bike Module
Service Module
Staff Module
Module Description
Login Module
This module deals with authentication to the application. The user can login to the
application by entering the username and password.
Booking Module
DBMS
12
13
This module deals with the booking add new booking and set the delivery date etc
managed by the admin . Also deals with the update and the delete operation for the booking.
Bike Module
This module deals with Bike managing the stock details also managed by the
admin . Also bike module is also delas with update delete operations for the booking.
Service Module
This module deals with the service section to service the bike it will need to register
by the admin , admin will set a staff for each service. And also the update and delete option will
be there.
Staff Module
This modules deals with the staff details admin will manage the adding updating
deleting.
Database Design
1. Login Table Design
DBMS
13
14
DBMS
14
15
This Login page provides the validation to an admin. The user can access the application by entering username
and password.
Source Code :
Imports System.Data
Imports MySql.Data.MySqlClient
Public Class login
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("Enter the username")
ElseIf TextBox2.Text = "" Then
MsgBox("Enter password")
End If
Dim com As String
com = "select name,pass from admin_log where name = '" + TextBox1.Text + "' ;"
Dim conn As New MySqlConnection
Dim DatabaseName As String = "ktm"
Dim server As String = "localhost"
Dim userName As String = "root"
Dim password As String = "jagan"
Dim pwd As String
If Not conn Is Nothing Then conn.Close()
conn.ConnectionString = String.Format("server={0}; user id={1}; password={2}; database={3}; pooling=false",
server, userName, password, DatabaseName)
Try
conn.Open()
Dim adp As MySqlDataAdapter = New MySqlDataAdapter(com, conn)
Dim ds As DataSet = New DataSet()
adp.Fill(ds)
If ds.Tables(0).CreateDataReader.HasRows Then
DBMS
15
16
pwd = ds.Tables(0).Rows(0)(1)
If pwd = TextBox2.Text Then
MsgBox("Welcome")
MDIParent1.Show()
Me.Hide()
Else
MsgBox("Invalid Login")
End If
' fname.Text = ds.Tables(0).Rows(0)(1)
'welcom.Show()
'Me.Hide()
Else
MsgBox("No Data Found")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
End Class
Home Page
DBMS
16
17
Source Code :
Imports System.Data
Imports MySql.Data.MySqlClient
Public Class bike_ktm
DBMS
17
18
DBMS
18
19
Source Code :
Imports System.Data
Imports MySql.Data.MySqlClient
Public Class staff_ktm
DBMS
19
20
21
End Sub
Private Sub staff_ktm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
End Sub
End Class
Booking Form
Source Code :
Imports System.Data
Imports MySql.Data.MySqlClient
Public Class book_add
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
DBMS
21
22
22
23
23
24
End Sub
End Class
Service Form
Source Code :
Imports System.Data
Imports MySql.Data.MySqlClient
Public Class service_ktm
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim conn As New MySqlConnection
DBMS
24
25
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
25
26
End If
Next
End Sub
End Class
Source Code :
Private Sub Button1_Click(ByVal
System.EventArgs) Handles Button1.Click
sender
As
System.Object,
ByVal
As
26
27
sta_na.Text = ds.Tables(0).Rows(0)(1)
sta_add.Text = ds.Tables(0).Rows(0)(2)
sta_gen.Text = ds.Tables(0).Rows(0)(3)
Else
MsgBox("No Data Found")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
Dim conn As New MySqlConnection
Dim DatabaseName As String = "ktm"
Dim server As String = "localhost"
DBMS
27
28
End Sub
28
DBMS
29
30
Source Code :
Private Sub Button1_Click(ByVal
System.EventArgs) Handles Button1.Click
sender
As
System.Object,
ByVal
As
30
31
modelname.Text = ds.Tables(0).Rows(0)(1)
regnum.Text = ds.Tables(0).Rows(0)(2)
ownername.Text = ds.Tables(0).Rows(0)(3)
problem.Text = ds.Tables(0).Rows(0)(4)
dat.Text = ds.Tables(0).Rows(0)(5)
ddate.Text = ds.Tables(0).Rows(0)(6)
Else
MsgBox("No Data Found")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
Private Sub service_view_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Dim com As String
com = "select service_id from service_ktm;"
DBMS
31
32
End Sub
32
33
33
34
DBMS
34
35
End If
Next
End Sub
sender
As
System.Object,
ByVal
As
As
End Sub
End Class
Booking Update , Delete Form
Source Code :
Private Sub Button1_Click(ByVal
System.EventArgs) Handles Button1.Click
sender
As
System.Object,
ByVal
DBMS
35
'%h
36
%i
b_name.Text = ds.Tables(0).Rows(0)(1)
b_email.Text = ds.Tables(0).Rows(0)(2)
b_phone.Text = ds.Tables(0).Rows(0)(3)
b_address.Text = ds.Tables(0).Rows(0)(4)
b_idp.Text = ds.Tables(0).Rows(0)(5)
b_mod.Text = ds.Tables(0).Rows(0)(6)
b_price.Text = ds.Tables(0).Rows(0)(7)
b_bdat.Text = ds.Tables(0).Rows(0)(8)
b_del.Text = ds.Tables(0).Rows(0)(9)
b_status.Text = ds.Tables(0).Rows(0)(10)
b_staff.Text = ds.Tables(0).Rows(0)(11)
Else
DBMS
36
37
End Sub
37
38
End Try
conn.Close()
End Sub
38
39
End Sub
End Sub
End Class
DBMS
39
40
Source Code :
Private Sub search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
search.Click
Dim com As String
com = "select bike_id,bike_model,bike_price,bike_specification,bike_stock from bike_ktm
where bike_id = '" + cid.Text + "' ;"
Dim conn As New MySqlConnection
Dim DatabaseName As String = "ktm"
Dim server As String = "localhost"
Dim userName As String = "root"
Dim password As String = "jagan"
Dim comm As New MySqlCommand
If Not conn Is Nothing Then conn.Close()
conn.ConnectionString = String.Format("server={0}; user id={1}; password={2};
database={3}; pooling=false", server, userName, password, DatabaseName)
Try
conn.Open()
DBMS
40
41
model.Text = ds.Tables(0).Rows(0)(1)
price.Text = ds.Tables(0).Rows(0)(2)
spec.Text = ds.Tables(0).Rows(0)(3)
stock.Text = ds.Tables(0).Rows(0)(4)
Else
MsgBox("No Data Found")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim conn As New MySqlConnection
Dim DatabaseName As String = "ktm"
Dim server As String = "localhost"
Dim userName As String = "root"
Dim password As String = "jagan"
41
42
conn.Open()
com.Connection = conn
com.CommandText = "delete from bike_ktm where bike_id = '" + cid.Text + "';"
com.ExecuteNonQuery()
MsgBox("Deleted")
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
42
43
MsgBox("Updated")
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
Conclusion
This project is used to provide the easier management of a Bike showroom system. Admin Can
manage the entire showroom from this software. This System will convert all the manual work to
the computerized work , the admin can easily get more information which they want.
The Software includes Booking , Bike , Service , Staff
Modules Plus their updation deleting managing can be done by the admin i will reduce the paper
work on a Showroom data will never lose.
DBMS
43