0% found this document useful (0 votes)
31 views

Coding For Connection:-: "Provider SQLOLEDB Database Metro Integrated Security SSPI"

This document contains code for connecting to a database and performing CRUD (create, read, update, delete) operations on various tables. It includes code for: 1. Connecting to a SQL database and opening/closing the connection. 2. Logging in a user by querying the login table and validating credentials. 3. Adding, updating, deleting, and finding records in different tables like applicant, online admission, course, and student registration. 3. Refreshing fields after performing operations like find, update, delete.

Uploaded by

Rakhi Varshney
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Coding For Connection:-: "Provider SQLOLEDB Database Metro Integrated Security SSPI"

This document contains code for connecting to a database and performing CRUD (create, read, update, delete) operations on various tables. It includes code for: 1. Connecting to a SQL database and opening/closing the connection. 2. Logging in a user by querying the login table and validating credentials. 3. Adding, updating, deleting, and finding records in different tables like applicant, online admission, course, and student registration. 3. Refreshing fields after performing operations like find, update, delete.

Uploaded by

Rakhi Varshney
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 21

CODING FOR CONNECTION:Imports Microsoft.VisualBasic Imports system.data.

oledb Public Class connect Public con As New OleDbConnection("provider=SQLOLEDB;database=metro;integrated security=SSPI") End Class Login.aspx Imports System.Data.oledb Partial Class Default2 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Try c.con.open() Catch ex As Exception Response.Write(ex.ToString) End Try c.con.Close() End Sub Dim c As New connect CODING FOR LOGIN IN LOGIN FORM: Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_login.Click c.con.Open() Dim str As String = "select * from login" Dim dr As OleDbDataReader Dim cmd As New OleDbCommand(str, c.con) dr = cmd.ExecuteReader() While (dr.Read()) If txt_username.Text = dr("username").ToString() And txt_password.Text = dr("password").ToString() Then Response.Write("<script>alert('login successfully')</script>") Else Response.Write("<script>alert('invalid username,password,type')</script>") End If End While

dr.Close() c.con.Close() End Sub CODING FOR ADD IN LOGIN FORM:Protected Sub btn_add_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_add.Click c.con.Open() Dim str As String = "insert into login(username,password)values(' " + txt_username.Text + " ',' " + txt_password.Text+ " ')" Dim cmd As New OleDbCommand(str, c.con) cmd.ExecuteNonQuery() Response.Write("<script>alert('data saved')</script>") c.con.Close() End Sub End Class CODING FOR CANCEL IN LOGIN FORM:Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_cancel.Click txt_username.Text = "" txt_password.Text = "" End Sub Applicant.aspx Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("applicant") dr = dt.NewRow dr(0) = txt_appid.Text dr(1) = txt_firstname.Text dr(2) = txt_lastname.Text dr(3) = txt_fname.Text dr(4) = txt_age.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11, "applicant") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "******Data Saved******" Catch ex As Exception msg.Text = "***Database Not Ready***" End Try End Sub

Private Sub btmupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmupdate.Click Try Dim str As String str = txt_appid.Text dt = DataSet11.Tables("applicant") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_firstname.Text dr(2) = txt_lastname.Text dr(3) = txt_fname.Text dr(4) = txt_age.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11, "applicant") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data update**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmdelete.Click Try Dim str As String str = txt_appid.Text dt = DataSet11.Tables("applicant") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, "applicant") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "******Data Deleted*******" Catch ex As Exception msg.Text = "****Database Not ready****" End Try End Sub Private Sub btmfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmfind.Click Try Dim dr() As DataRow

dr = DataSet11.Tables("applicant").Select("appid ='" & txt_appid.Text & "'") txt_firstname.Text= dr(0)(1) txt_lastname.Text= dr(0)(2) txt_fname.Text= dr(0)(3) txt_age.Text= dr(0)(4) msg.Text = "******Data Found******" Catch ex As Exception msg.Text = "*****Data Not Found*****" End Try Private Sub btmrefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmrefresh.Click Try txt_appid.Text = "" txt_firstname.Text = "" txt_lastname.Text = "" txt_fname.Text = "" txt_age.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class ONLine admission.aspx Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here OleDbDataAdapter1.Fill(DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("online_admission") dr = dt.NewRow dr(0) = txt_admid.Text dr(1) = txt_fname.Text dr(2) = txt_lname.Text dr(3) = txt_age.Text dr(4) = txt_dob.Text dr(5) = txt_address.Text dr(6) = txt_capply.Text

dr(7) = txt_cid.Text dr(8) = txt_college.Text dr(9) = txt_markstwe.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11,"online_admission") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "********Data Saved********" Catch ex As Exception msg.Text = "*****Database Not Ready*****" End Try End Sub Private Sub btmupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmupdate.Click Try Dim str As String str = txt_admid.Text dt = DataSet11.Tables("online_admission") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_fname.Text dr(2) = txt_lname.Text dr(3) = txt_age.Text dr(4) = txt_dob.Text dr(5) = txt_address.Text dr(6) = txt_capply.Text dr(7) = txt_cid.Text dr(8) = txt_college.Text dr(9) = txt_markstwe.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11, "online_admission") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data update**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmdelete.Click Try Dim str As String str = txt_admid.Text

dt = DataSet11.Tables("online_admission") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, "online_admission") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data Deleted**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmfind.Click Try Dim dr() As DataRow dr = DataSet11.Tables("online_admission").Select("admission_id ='" & txt_admid.Text & "'") txt_fname.Text = dr(0)(1) txt_lname.Text = dr(0)(2) txt_age.Text = dr(0)(3) txt_dob.Text = dr(0)(4) txt_address.Text = dr(0)(5) txt_capply.Text = dr(0)(6) txt_cid.Text = dr(0)(7) txt_college.Text = dr(0)(8) txt_markstwe.Text = dr(0)(9) msg.Text = "********Data Found********" Catch ex As Exception msg.Text = "********Data Not Found********" End Try End Sub Private Sub btmrefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmrefresh.Click Try txt_admid.Text = "" txt_fname.Text = "" txt_lname.Text = "" txt_age.Text = "" txt_dob.Text = "" txt_address.Text = "" txt_capply.Text = "" txt_cid.Text = ""

txt_college.Text = "" txt_markstwe.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class Course.aspx Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here OleDbDataAdapter1.Fill(DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("course") dr = dt.NewRow dr(0) = txt_courseid.Text dr(1) = txt_coursename.Text dr(2) = txt_duration.Text dr(3) = txt_fees.Text dr(4) = txt_eligibility.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11, "course") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "********Data Saved********" Catch ex As Exception msg.Text = "*****Database Not Ready*****" End Try End Sub Private Sub btmupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmupdate.Click Try Dim str As String str = txt_courseid.Text dt = DataSet11.Tables("course") dr = dt.Rows.Find(str) dr.BeginEdit()

dr(1) = txt_coursename.Text dr(2) = txt_duration.Text dr(3) = txt_fees.Text dr(4) = txt_eligibility.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11, "course") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data update**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmdelete.Click Try Dim str As String str = txt_courseid.Text dt = DataSet11.Tables("course") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, "course") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data Deleted**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmfind.Click Try Dim dr() As DataRow dr = DataSet11.Tables("course").Select("course_id ='" & txt_courseid.Text & "'") txt_coursename.Text = dr(0)(1) txt_duration.Text = dr(0)(2) txt_fees.Text = dr(0)(3) txt_eligibility.Text = dr(0)(4) msg.Text = "********Data Found********" Catch ex As Exception msg.Text = "********Data Not Found********" End Try

End Sub Private Sub btmrefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmrefresh.Click Try txt_courseid.Text = "" txt_coursename.Text = "" txt_duration.Text = "" txt_fees.Text = "" txt_eligibility.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class Student registration.aspx Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here OleDbDataAdapter1.Fill(DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("student registration") dr = dt.NewRow dr(0) = txt_studentidText dr(1) = txt_passwd.Text dr(2) = txt_name.Text dr(3) = txt_fathersname.Text dr(4) = txt_age.Text dr(5) = txt_dob.Text dr(6) = txt_address.Text dr(7) = txt_phone_no.Text dr(8) = txt_session.Text dr(9) = txt_courseid.Text dr(10) = txt_coursename.Text dr(11) = txt_dept.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11, " student registration ") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "********Data Saved********"

Catch ex As Exception msg.Text = "*****Database Not Ready*****" End Try End Sub Private Sub btmupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmupdate.Click Try Dim str As String str = txt_studentid.Text dt = DataSet11.Tables("student registration") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_passwd.Text dr(2) = txt_name.Text dr(3) = txt_fathersname.Text dr(4) = txt_age.Text dr(5) = txt_dob.Text dr(6) = txt_address.Text dr(7) = txt_phone_no.Text dr(8) = txt_session.Text dr(9) = txt_courseid.Text dr(10) = txt_coursename.Text dr(11) = txt_dept.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11, " student registration ") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data update**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmdelete.Click Try Dim str As String str = txt_studentid.Text dt = DataSet11.Tables("student registration") dr = dt.Rows.Find(str) dr.Delete()

OleDbDataAdapter1.Update(DataSet11, " student registration") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data Deleted**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmfind.Click Try Dim dr() As DataRow dr = DataSet11.Tables("student registration").Select("student_id ='" & txt_studentid.Text & "'") txt_passwd.Text = dr(0)(1) txt_name.Text = dr(0)(2) txt_fathersname.Text = dr(0)(3) txt_age.Text = dr(0)(4) txt_dob.Text = dr(0)(5) txt_address.Text = dr(0)(6) txt_phone_no.Text = dr(0)(7) txt_session.Text = dr(0)(8) txt_courseid.Text = dr(0)(9) txt_coursename.Text = dr(0)(10) txt_dept.Text = dr(0)(11) msg.Text = "********Data Found********" Catch ex As Exception msg.Text = "********Data Not Found********" End Try End Sub Private Sub btmrefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmrefresh.Click Try txt_studentid.Text = "" txt_name.Text = "" txt_fathersname.Text = "" txt_age.Text = "" txt_dob.Text = "" txt_address.Text = "" txt_phone_no.Text = "" txt_session.Text = "" txt_courseid.Text = ""

txt_coursename.Text = "" txt_dept.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class STUDENT FORUM .aspx Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here OleDbDataAdapter1.Fill(DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("student forum") dr = dt.NewRow dr(0) = txt_forumno.Text dr(1) = txt_emailid.Text dr(2) = txt_phoneno.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11,"student forum") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "********Data Saved********" Catch ex As Exception msg.Text = "*****Database Not Ready*****" End Try End Sub Private Sub btmupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmupdate.Click Try Dim str As String str = txt_forumno.Text dt = DataSet11.Tables("student forum") dr = dt.Rows.Find(str) dr.BeginEdit()

dr(1) = txt_emailid.Text dr(2) = txt_phoneno.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11," student forum") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data update**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmdelete.Click Try Dim str As String str = txt_forumno.Text dt = DataSet11.Tables("student forum") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11,"student forum") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data Deleted**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmfind.Click Try Dim dr() As DataRow dr = DataSet11.Tables("student forum ").Select("forum_no. ='" & txt_forumno.Text & "'") txt_emailid.Text = dr(0)(1) txt_phoneno.Text = dr(0)(2) msg.Text = "********Data Found********" Catch ex As Exception msg.Text = "********Data Not Found********" End Try End Sub Private Sub btmrefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmrefresh.Click Try

txt_forumno.Text = "" txt_emailid.Text = "" txt_phoneno.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class EMPLOYEE REGISTRATION.ASPX Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here OleDbDataAdapter1.Fill(DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("employee registration") dr = dt.NewRow dr(0) = txt_employeeid.Text dr(1) = txt_passwd.Text dr(2) = txt_name.Text dr(3) = txt_age.Text dr(4) = txt_dob.Text dr(5) = txt_address.Text dr(6) = txt_phone_no.Text dr(7) = txt_emailid.Text dr(8) = txt_designation.Text dr(19) = txt_salary.Text dr(10) = txt_joining.Text dr(11) = txt_department.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11, " employee registration ") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "********Data Saved********" Catch ex As Exception msg.Text = "*****Database Not Ready*****" End Try End Sub

Private Sub btmupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmupdate.Click Try Dim str As String str = txt_employeeid.Text dt = DataSet11.Tables("employee registration") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_passwd.Text dr(2) = txt_name.Text dr(3) = txt_age.Text dr(4) = txt_dob.Text dr(5) = txt_address.Text dr(6) = txt_phone_no.Text dr(7) = txt_emailid.Text dr(8) = txt_designation.Text dr(9) = txt_salary.Text dr(10) = txt_joining.Text dr(11) = txt_department.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11,"employee registration") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data update**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmdelete.Click Try Dim str As String str = txt_employeeid.Text dt = DataSet11.Tables("employee registration") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, " employee registration") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data Deleted**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub

Private Sub btmfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmfind.Click Try Dim dr() As DataRow dr = DataSet11.Tables("employee registration").Select("employee_id ='" & txt_employeeid.Text & "'") txt_passwd.Text = dr(0)(1) txt_name.Text = dr(0)(2) txt_age.Text = dr(0)(3) txt_dob.Text = dr(0)(4) txt_address.Text = dr(0)(5) txt_phone_no.Text = dr(0)(6) txt_emailid.Text = dr(0)(7) txt_designation.Text = dr(0)(8) txt_salary.Text = dr(0)(9) txt_joining.Text = dr(0)(10) txt_department.Text = dr(0)(11) msg.Text = "********Data Found********" Catch ex As Exception msg.Text = "********Data Not Found********" End Try End Sub Private Sub btmrefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmrefresh.Click Try txt_employeeid.Text = "" txt_name.Text = "" txt_age.Text = "" txt_dob.Text = "" txt_address.Text = "" txt_phone_no.Text = "" txt_emailid.Text = "" txt_designation.Text = "" txt_salary.Text = "" txt_joining.Text = "" txt_department.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class

ONLINE JOB TABLE: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here OleDbDataAdapter1.Fill(DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("online_job") dr = dt.NewRow dr(0) = txt_firstname.Text dr(1) = txt_lastname.Text dr(2) = txt_sex.Text dr(3) = txt_age.Text dr(4) = txt_dob.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11,"online_job") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "********Data Saved********" Catch ex As Exception msg.Text = "*****Database Not Ready*****" End Try End Sub Private Sub btmupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmupdate.Click Try Dim str As String str = txt_firstname.Text dt = DataSet11.Tables("online_job") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_lastname.Text dr(2) = txt_sex.Text dr(3) = txt_age.Text dr(4) = txt_dob.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11,"online_job") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data update**********" Catch ex As Exception

msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmdelete.Click Try Dim str As String str = txt_firstname.Text dt = DataSet11.Tables("online_job") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, "online_job") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data Deleted**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmfind.Click Try Dim dr() As DataRow dr = DataSet11.Tables("online_job").Select("firstname ='" & txt_firstname.Text & "'") txt_coursename.Text = dr(0)(1) txt_duration.Text = dr(0)(2) txt_fees.Text = dr(0)(3) txt_eligibility.Text = dr(0)(4) msg.Text = "********Data Found********" Catch ex As Exception msg.Text = "********Data Not Found********" End Try End Sub Private Sub btmrefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmrefresh.Click Try txt_firstname.Text = "" txt_lastname.Text = "" txt_sex.Text = "" txt_age.Text = ""

txt_dob.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class Department table Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here OleDbDataAdapter1.Fill(DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("department") dr = dt.NewRow dr(0) = txt_department.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11,"department") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "********Data Saved********" Catch ex As Exception msg.Text = "*****Database Not Ready*****" End Try End Sub Private Sub btmupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmupdate.Click Try Dim str As String str = txt_departmentid.Text dt = DataSet11.Tables("department") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_departmentname.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11,"department") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data update**********" Catch ex As Exception

msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmdelete.Click Try Dim str As String str = txt_departmentid.Text dt = DataSet11.Tables("department") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11,"department") OleDbDataAdapter1.Fill(DataSet11) msg.Text = "*********Data Deleted**********" Catch ex As Exception msg.Text = "*****Database Not ready*****" End Try End Sub Private Sub btmfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmfind.Click Try Dim dr() As DataRow dr = DataSet11.Tables("department ").Select("departmentid. ='" & txt_departmentid.Text & "'") txt_departmentname.Text = dr(0)(1) msg.Text = "********Data Found********" Catch ex As Exception msg.Text = "********Data Not Found********" End Try End Sub Private Sub btmrefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmrefresh.Click Try txt_departmentid.Text = "" txt_departmentname.Text = "" txt_phoneno.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub

End Class

You might also like