0% found this document useful (0 votes)
12 views21 pages

ASP.NET Login and Admission System Code

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)
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)
12 views21 pages

ASP.NET Login and Admission System Code

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

CODING FOR CONNECTION:Imports [Link] Imports [Link].

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

[Link]() [Link]() End Sub CODING FOR ADD IN LOGIN FORM:Protected Sub btn_add_Click(ByVal sender As Object, ByVal e As [Link]) Handles btn_add.Click [Link]() Dim str As String = "insert into login(username,password)values(' " + txt_username.Text + " ',' " + txt_password.Text+ " ')" Dim cmd As New OleDbCommand(str, [Link]) [Link]() [Link]("<script>alert('data saved')</script>") [Link]() End Sub End Class CODING FOR CANCEL IN LOGIN FORM:Protected Sub Button3_Click(ByVal sender As Object, ByVal e As [Link]) Handles btn_cancel.Click txt_username.Text = "" txt_password.Text = "" End Sub [Link] Private Sub btmadd_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try dt = [Link]("applicant") dr = [Link] 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 [Link](dr) [Link](DataSet11, "applicant") [Link](DataSet11) [Link] = "******Data Saved******" Catch ex As Exception [Link] = "***Database Not Ready***" End Try End Sub

Private Sub btmupdate_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_appid.Text dt = [Link]("applicant") dr = [Link](str) [Link]() dr(1) = txt_firstname.Text dr(2) = txt_lastname.Text dr(3) = txt_fname.Text dr(4) = txt_age.Text [Link]() [Link](DataSet11, "applicant") [Link](DataSet11) [Link] = "*********Data update**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_appid.Text dt = [Link]("applicant") dr = [Link](str) [Link]() [Link](DataSet11, "applicant") [Link](DataSet11) [Link] = "******Data Deleted*******" Catch ex As Exception [Link] = "****Database Not ready****" End Try End Sub Private Sub btmfind_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim dr() As DataRow

dr = [Link]("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) [Link] = "******Data Found******" Catch ex As Exception [Link] = "*****Data Not Found*****" End Try Private Sub btmrefresh_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try txt_appid.Text = "" txt_firstname.Text = "" txt_lastname.Text = "" txt_fname.Text = "" txt_age.Text = "" [Link] = "" Catch ex As Exception End Try End Sub End Class ONLine [Link] Private Sub Page_Load(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] 'Put user code to initialize the page here [Link](DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try dt = [Link]("online_admission") dr = [Link] 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 [Link](dr) [Link](DataSet11,"online_admission") [Link](DataSet11) [Link] = "********Data Saved********" Catch ex As Exception [Link] = "*****Database Not Ready*****" End Try End Sub Private Sub btmupdate_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_admid.Text dt = [Link]("online_admission") dr = [Link](str) [Link]() 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 [Link]() [Link](DataSet11, "online_admission") [Link](DataSet11) [Link] = "*********Data update**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_admid.Text

dt = [Link]("online_admission") dr = [Link](str) [Link]() [Link](DataSet11, "online_admission") [Link](DataSet11) [Link] = "*********Data Deleted**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmfind_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim dr() As DataRow dr = [Link]("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) [Link] = "********Data Found********" Catch ex As Exception [Link] = "********Data Not Found********" End Try End Sub Private Sub btmrefresh_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] 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 = "" [Link] = "" Catch ex As Exception End Try End Sub End Class [Link] Private Sub Page_Load(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] 'Put user code to initialize the page here [Link](DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try dt = [Link]("course") dr = [Link] 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 [Link](dr) [Link](DataSet11, "course") [Link](DataSet11) [Link] = "********Data Saved********" Catch ex As Exception [Link] = "*****Database Not Ready*****" End Try End Sub Private Sub btmupdate_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_courseid.Text dt = [Link]("course") dr = [Link](str) [Link]()

dr(1) = txt_coursename.Text dr(2) = txt_duration.Text dr(3) = txt_fees.Text dr(4) = txt_eligibility.Text [Link]() [Link](DataSet11, "course") [Link](DataSet11) [Link] = "*********Data update**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_courseid.Text dt = [Link]("course") dr = [Link](str) [Link]() [Link](DataSet11, "course") [Link](DataSet11) [Link] = "*********Data Deleted**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmfind_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim dr() As DataRow dr = [Link]("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) [Link] = "********Data Found********" Catch ex As Exception [Link] = "********Data Not Found********" End Try

End Sub Private Sub btmrefresh_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try txt_courseid.Text = "" txt_coursename.Text = "" txt_duration.Text = "" txt_fees.Text = "" txt_eligibility.Text = "" [Link] = "" Catch ex As Exception End Try End Sub End Class Student [Link] Private Sub Page_Load(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] 'Put user code to initialize the page here [Link](DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try dt = [Link]("student registration") dr = [Link] 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 [Link](dr) [Link](DataSet11, " student registration ") [Link](DataSet11) [Link] = "********Data Saved********"

Catch ex As Exception [Link] = "*****Database Not Ready*****" End Try End Sub Private Sub btmupdate_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_studentid.Text dt = [Link]("student registration") dr = [Link](str) [Link]() 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 [Link]() [Link](DataSet11, " student registration ") [Link](DataSet11) [Link] = "*********Data update**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_studentid.Text dt = [Link]("student registration") dr = [Link](str) [Link]()

[Link](DataSet11, " student registration") [Link](DataSet11) [Link] = "*********Data Deleted**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmfind_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim dr() As DataRow dr = [Link]("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) [Link] = "********Data Found********" Catch ex As Exception [Link] = "********Data Not Found********" End Try End Sub Private Sub btmrefresh_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] 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 = "" [Link] = "" Catch ex As Exception End Try End Sub End Class STUDENT FORUM .aspx Private Sub Page_Load(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] 'Put user code to initialize the page here [Link](DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try dt = [Link]("student forum") dr = [Link] dr(0) = txt_forumno.Text dr(1) = txt_emailid.Text dr(2) = txt_phoneno.Text [Link](dr) [Link](DataSet11,"student forum") [Link](DataSet11) [Link] = "********Data Saved********" Catch ex As Exception [Link] = "*****Database Not Ready*****" End Try End Sub Private Sub btmupdate_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_forumno.Text dt = [Link]("student forum") dr = [Link](str) [Link]()

dr(1) = txt_emailid.Text dr(2) = txt_phoneno.Text [Link]() [Link](DataSet11," student forum") [Link](DataSet11) [Link] = "*********Data update**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_forumno.Text dt = [Link]("student forum") dr = [Link](str) [Link]() [Link](DataSet11,"student forum") [Link](DataSet11) [Link] = "*********Data Deleted**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmfind_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim dr() As DataRow dr = [Link]("student forum ").Select("forum_no. ='" & txt_forumno.Text & "'") txt_emailid.Text = dr(0)(1) txt_phoneno.Text = dr(0)(2) [Link] = "********Data Found********" Catch ex As Exception [Link] = "********Data Not Found********" End Try End Sub Private Sub btmrefresh_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try

txt_forumno.Text = "" txt_emailid.Text = "" txt_phoneno.Text = "" [Link] = "" Catch ex As Exception End Try End Sub End Class EMPLOYEE [Link] Private Sub Page_Load(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] 'Put user code to initialize the page here [Link](DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try dt = [Link]("employee registration") dr = [Link] 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 [Link](dr) [Link](DataSet11, " employee registration ") [Link](DataSet11) [Link] = "********Data Saved********" Catch ex As Exception [Link] = "*****Database Not Ready*****" End Try End Sub

Private Sub btmupdate_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_employeeid.Text dt = [Link]("employee registration") dr = [Link](str) [Link]() 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 [Link]() [Link](DataSet11,"employee registration") [Link](DataSet11) [Link] = "*********Data update**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_employeeid.Text dt = [Link]("employee registration") dr = [Link](str) [Link]() [Link](DataSet11, " employee registration") [Link](DataSet11) [Link] = "*********Data Deleted**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub

Private Sub btmfind_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim dr() As DataRow dr = [Link]("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) [Link] = "********Data Found********" Catch ex As Exception [Link] = "********Data Not Found********" End Try End Sub Private Sub btmrefresh_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] 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 = "" [Link] = "" Catch ex As Exception End Try End Sub End Class

ONLINE JOB TABLE: Private Sub Page_Load(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] 'Put user code to initialize the page here [Link](DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try dt = [Link]("online_job") dr = [Link] 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 [Link](dr) [Link](DataSet11,"online_job") [Link](DataSet11) [Link] = "********Data Saved********" Catch ex As Exception [Link] = "*****Database Not Ready*****" End Try End Sub Private Sub btmupdate_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_firstname.Text dt = [Link]("online_job") dr = [Link](str) [Link]() dr(1) = txt_lastname.Text dr(2) = txt_sex.Text dr(3) = txt_age.Text dr(4) = txt_dob.Text [Link]() [Link](DataSet11,"online_job") [Link](DataSet11) [Link] = "*********Data update**********" Catch ex As Exception

[Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_firstname.Text dt = [Link]("online_job") dr = [Link](str) [Link]() [Link](DataSet11, "online_job") [Link](DataSet11) [Link] = "*********Data Deleted**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmfind_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim dr() As DataRow dr = [Link]("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) [Link] = "********Data Found********" Catch ex As Exception [Link] = "********Data Not Found********" End Try End Sub Private Sub btmrefresh_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try txt_firstname.Text = "" txt_lastname.Text = "" txt_sex.Text = "" txt_age.Text = ""

txt_dob.Text = "" [Link] = "" Catch ex As Exception End Try End Sub End Class Department table Private Sub Page_Load(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] 'Put user code to initialize the page here [Link](DataSet11) End Sub Private Sub btmadd_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try dt = [Link]("department") dr = [Link] dr(0) = txt_department.Text [Link](dr) [Link](DataSet11,"department") [Link](DataSet11) [Link] = "********Data Saved********" Catch ex As Exception [Link] = "*****Database Not Ready*****" End Try End Sub Private Sub btmupdate_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_departmentid.Text dt = [Link]("department") dr = [Link](str) [Link]() dr(1) = txt_departmentname.Text [Link]() [Link](DataSet11,"department") [Link](DataSet11) [Link] = "*********Data update**********" Catch ex As Exception

[Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmdelete_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim str As String str = txt_departmentid.Text dt = [Link]("department") dr = [Link](str) [Link]() [Link](DataSet11,"department") [Link](DataSet11) [Link] = "*********Data Deleted**********" Catch ex As Exception [Link] = "*****Database Not ready*****" End Try End Sub Private Sub btmfind_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim dr() As DataRow dr = [Link]("department ").Select("departmentid. ='" & txt_departmentid.Text & "'") txt_departmentname.Text = dr(0)(1) [Link] = "********Data Found********" Catch ex As Exception [Link] = "********Data Not Found********" End Try End Sub Private Sub btmrefresh_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try txt_departmentid.Text = "" txt_departmentname.Text = "" txt_phoneno.Text = "" [Link] = "" Catch ex As Exception End Try End Sub

End Class

You might also like