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

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

This document contains code for connecting to a database and performing CRUD (create, read, update, delete) operations on various tables in the database related to user login, staff details, staff salary, course details, and courses taken. The code uses OleDb to connect to the database and perform SQL queries and updates. Functions include adding, updating, deleting, and finding data in the different tables.

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)
20 views

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

This document contains code for connecting to a database and performing CRUD (create, read, update, delete) operations on various tables in the database related to user login, staff details, staff salary, course details, and courses taken. The code uses OleDb to connect to the database and perform SQL queries and updates. Functions include adding, updating, deleting, and finding data in the different tables.

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/ 19

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 Staff detail.aspx Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("staff detail") dr = dt.NewRow dr(0) = txt_staffid.Text dr(1) = txt_name.Text dr(2) = txt_address.Text dr(3) = txt_phoneno.Text dr(4) = txt_DOB.Text dr(5) = txt_DOJ.Text dr(6) = txt_designation.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11, "staff detail") 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_staffid.Text dt = DataSet11.Tables("staff detail") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_name.Text dr(2) = txt_address.Text dr(3) = txt_phoneno.Text dr(4) = txt_DOB.Text dr(5) = txt_DOJ.Text dr(6) = txt_designation.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11, "staff detail") 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_staffid.Text dt = DataSet11.Tables("staff detail") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, "staff detail") 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("staff detail").Select("staffid ='" & txt_staffid.Text & "'")

txt_name.Text = dr(0)(1) txt_address.Text = dr(0)(2) txt_phoneno.Text = dr(0)(3) txt_DOB.Text = dr(0)(4) txt_DOJ.Text = dr(0)(5) txt_designation.Text = dr(0)(6) 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_staffid.Text = "" txt_name.Text = "" txt_address.Text = "" txt_phoneno.Text = "" txt_DOB.Text = "" txt_DOJ.Text = "" txt_designation.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class Staff salary.aspx Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("staff salary") dr = dt.NewRow dr(0) = txt_serialno.Text dr(1) = txt_staffid.Text dr(2) = txt_name.Text dr(3) = txt_month.Text dr(4) = txt_attendingdays.Text dr(5) = txt_absentdays.Text dr(6) = txt_presentdaysalary.Text dr(7) = txt_DA.Text dr(8) = txt_TA.Text dr(9) = txt_HRA.Text

dr(10) = txt_dateofsalary.Text dr(11) = txt_nettotalsalary.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11, "staff salary) 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_serialno.Text dt = DataSet11.Tables("staff salary") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_staffid.Text dr(2) = txt_name.Text dr(3) = txt_month.Text dr(4) = txt_attendingdays.Text dr(5) = txt_absentdays.Text dr(6) = txt_presentdaysalary.Text dr(7) = txt_DA.Text dr(8) = txt_TA.Text dr(9) = txt_HRA.Text dr(10) = txt_dateofsalary.Text dr(11) = txt_nettotalsalary.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11, "staff salary") 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_serialno.Text

dt = DataSet11.Tables("staff salary") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, "staff salary") 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("staff salary").Select("serial no. ='" & txt_serialno.Text & "'") txt_staffid.Text = dr(0)(1) txt_name.Text = dr(0)(2) txt_month.Text = dr(0)(3) txt_attendingdays.Text = dr(0)(4) txt_absentdays.Text = dr(0)(5) txt_presentdaysalary.Text = dr(0)(6) txt_DA.Text = dr(0)(7) txt_TA.Text = dr(0)(8) txt_HRA.Text = dr(0)(9) txt_dateofsalary.Text = dr(0)(10) txt_nettotalsalary.Text = dr(0)(11) 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_serialno.Text = "" txt_staffid.Text = "" txt_name.Text = "" txt_month.Text = "" txt_attendingdays.Text = "" txt_absentdays.Text = "" txt_presentdaysalary.Text = "" txt_DA.Text = ""

txt_TA.Text = "" txt_HRA.Text = "" txt_dateofsalary.Text = "" txt_nettotalsalary.Text = "" Catch ex As Exception End Try End Sub End Class Course detail.aspx Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("course detail") dr = dt.NewRow dr(0) = txt_courseid.Text dr(1) = txt_coursename.Text dr(2) = txt_duration.Text dr(3) = txt_coursefees.Text dr(4) = txt_courselink.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11, "course detail") 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 detail") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_coursename.Text dr(2) = txt_duration.Text dr(3) = txt_coursefees.Text dr(4) = txt_courselink.Text

dr.EndEdit() OleDbDataAdapter1.Update(DataSet11, "course detail") 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 detail") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, "course detail") 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 detail").Select("courseid ='" & txt_courseid.Text & "'") txt_coursename.Text = dr(0)(1) txt_duration.Text = dr(0)(2) txt_coursefees.Text = dr(0)(3) txt_courselink.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_courseid.Text = ""

txt_coursename.Text = "" txt_duration.Text = "" txt_coursefees.Text = "" txt_courselink.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class Courses taken.aspx Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("course taken") dr = dt.NewRow dr(0) = txt_studentid.Text dr(1) = txt_courseid.Text dr(2) = txt_term.Text dr(3) = txt_grade.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11, "course taken") 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("course taken") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_courseid.Text dr(2) = txt_term.Text dr(3) = txt_grade.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11, "course taken") 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("course taken") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, "course taken") 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 taken").Select("studentid ='" & txt_studentid.Text & "'") txt_courseid.Text = dr(0)(1) txt_term.Text = dr(0)(2) txt_grade.Text = dr(0)(3) 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_studentid.Text = "" txt_courseid.Text = "" txt_term.Text = "" txt_grade.Text = "" msg.Text = ""

Catch ex As Exception End Try End Sub End Class Student detail.aspx Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("student detail") dr = dt.NewRow dr(0) = txt_studentid.Text dr(1) = txt_firstname.Text dr(2) = txt_lastname.Text dr(3) = txt_gender.Text dr(4) = txt_DOB.Text dr(5) = txt_address.Text dr(6) = txt_yearenrolled.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11, "student detail") 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 detail") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_firstname.Text dr(2) = txt_lastname.Text dr(3) = txt_gender.Text dr(4) = txt_DOB.Text dr(5) = txt_address.Text dr(6) = txt_yearenrolled.Text

dr.EndEdit() OleDbDataAdapter1.Update(DataSet11, "student detail") 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 detail") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, "student detail") 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 detail").Select("studentid ='" & txt_studentid.Text & "'") txt_firstname.Text = dr(0)(1) txt_lastname.Text = dr(0)(2) txt_gender.Text = dr(0)(3) txt_DOB.Text = dr(0)(4) txt_address.Text = dr(0)(5) txt_yearenrolled.Text = dr(0)(6) 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_studentid.Text = "" txt_firstname.Text = "" txt_lastname.Text = "" txt_gender.Text = "" txt_DOB.Text = "" txt_address.Text = "" txt_yearenrolled.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class Instructor detail.aspx Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("instructor detail") dr = dt.NewRow dr(0) = txt_instid.Text dr(1) = txt_firstname.Text dr(2) = txt_lastname.Text dr(3) = txt_gender.Text dr(4) = txt_DOB.Text dr(5) = txt_address.Text dr(6) = txt_homepage.Text dr(7) = txt_yearenrolled.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11, "instructor detail") 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_instid.Text dt = DataSet11.Tables("instructor detail") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_firstname.Text dr(2) = txt_lastname.Text dr(3) = txt_gender.Text dr(4) = txt_DOB.Text dr(5) = txt_address.Text dr(6) = txt_homepage.Text dr(7) = txt_yearenrolled.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11, "instructor detail") 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_instid.Text dt = DataSet11.Tables("instructor detail") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, "instructor detail") 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("instructror detail").Select("instid ='" & txt_instid.Text & "'") txt_firstname.Text = dr(0)(1) txt_lastname.Text = dr(0)(2) txt_gender.Text = dr(0)(3)

txt_DOB.Text = dr(0)(4) txt_address.Text = dr(0)(5) txt_homepage.Text = dr(0)(6) txt_yearenrolled.Text = dr(0)(7) 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_instid.Text = "" txt_firstname.Text = "" txt_lastname.Text = "" txt_gender.Text = "" txt_DOB.Text = "" txt_address.Text = "" txt_homepage.Text = "" txt_yearenrolled.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class University detail.aspx Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("university detail") dr = dt.NewRow dr(0) = txt_uid.Text dr(1) = txt_uname.Text dr(2) = txt_uaddress.Text dr(3) = txt_uphoneno.Text dr(4) = txt_ucourses.Text dr(5) = txt_uemail.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11, "university detail")

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_uid.Text dt = DataSet11.Tables("university detail") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_uname.Text dr(2) = txt_uaddress.Text dr(3) = txt_uphoneno.Text dr(4) = txt_ucourses.Text dr(5) = txt_uemail.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11, "university detail") 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_uid.Text dt = DataSet11.Tables("university detail") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, "university detail") 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("university detail").Select("uid ='" & txt_uid.Text & "'") txt_uname.Text = dr(0)(1) txt_uaddress.Text = dr(0)(2) txt_uphoneno.Text = dr(0)(3) txt_ucourses.Text = dr(0)(4) txt_uemail.Text = dr(0)(5) 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_uid.Text = "" txt_uname.Text = "" txt_uaddress.Text = "" txt_uphoneno.Text = "" txt_ucourses.Text = "" txt_uemail.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class Registration detail.aspx Private Sub btmadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmadd.Click Try dt = DataSet11.Tables("registration detail") dr = dt.NewRow dr(0) = txt_regid.Text dr(1) = txt_courseid.Text dr(2) = txt_coursename.Text dr(3) = txt_studentid.Text dr(4) = txt_studentname.Text dr(5) = txt_coursefees.Text

dr(6) = txt_yearenrolled.Text dt.Rows.Add(dr) OleDbDataAdapter1.Update(DataSet11, "registration detail") 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_regid.Text dt = DataSet11.Tables("registration detail") dr = dt.Rows.Find(str) dr.BeginEdit() dr(1) = txt_courseid.Text dr(2) = txt_coursename.Text dr(3) = txt_studentid.Text dr(4) = txt_studentname.Text dr(5) = txt_coursefees.Text dr(6) = txt_yearenrolled.Text dr.EndEdit() OleDbDataAdapter1.Update(DataSet11, "registration detail") 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_regid.Text dt = DataSet11.Tables("registration detail") dr = dt.Rows.Find(str) dr.Delete() OleDbDataAdapter1.Update(DataSet11, "registration detail") 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("registration detail").Select("regid ='" & txt_regid.Text & "'") txt_courseid.Text = dr(0)(1) txt_coursename.Text = dr(0)(2) txt_studentid.Text = dr(0)(3) txt_studentname.Text = dr(0)(4) txt_coursefees.Text = dr(0)(5) txt_yearenrolled.Text = dr(0)(6) 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_regid.Text = "" txt_courseid.Text = "" txt_coursename.Text = "" txt_studentid.Text = "" txt_studentname.Text = "" txt_coursefees.Text = "" txt_yearenrolled.Text = "" msg.Text = "" Catch ex As Exception End Try End Sub End Class

You might also like