Imports System. Data. OleDb Public Class Login ‘this codes are the declarations for sql statement Dim connstring As String = ” Provider= Microsoft. Jet. OLEDB. 4. 0; Data Source = ” & Application. StartupPath & ” enlistment. mdb;” Dim con As New OleDbConnection(connstring) Dim com As OleDbCommand Dim ds As New DataSet Dim adapter As New OleDbDataAdapter Dim reader As OleDbDataReader Dim User As String Private Sub Form1_Load(ByVal sender As System. Object, ByVal e As System. EventArgs) Handles MyBase. Load AcceptButton = Me. Button1 ‘this codes will hide or disable a label, textbox and a button Me. Label4. Hide() Me. Label7. Hide() Me. Label8. Hide() Me. Button3. Hide() Me. TextBox1. Enabled = False Me. TextBox2. Enabled = False Me. Button1. Enabled = False ‘this codes will show the current time in the form log in Me. Timer1. Enabled = True Me. Timer1. Interval = 1 End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System. Object, ByVal e As System. EventArgs) Handles ComboBox1. SelectedIndexChanged ‘this codes will show or hide a label and button, enable a button and textbox, and will clear a textbox and combobox If ComboBox1. Text = ” Student” Then Me. Label4. Show() Me. TextBox1. Enabled = True Me. TextBox2. Enabled = True Me. Button1. Enabled = True Me. Label7. Hide() Me. Label8. Hide() TextBox1. Clear() ComboBox1. Text = “” TextBox2. Clear() Me. Button3. Hide() ElseIf ComboBox1. Text = ” Faculty” Then Me. Label4. Show() Me. TextBox1. Enabled = True Me. TextBox2. Enabled = True Me. Button1. Enabled = True Me. Label7. Hide() Me. Label8. Hide() TextBox1. Clear() ComboBox1. Text = “” TextBox2. Clear() Me. Button3. Hide() Else Me. Label4. Hide() Me. TextBox1. Enabled = False Me. TextBox2. Enabled = False Me. Button1. Enabled = False Me. Label7. Hide() Me. Label8. Hide() Me. Button3. Hide() TextBox1. Clear() ComboBox1. Text = “” TextBox2. Clear() End If End Sub Private Sub Button1_Click(ByVal sender As System. Object, ByVal e As System. EventArgs) Handles Button1. Click ‘this codes are used for the log in process Try If ComboBox1. Text = ” Student” Then ‘this codes will open the database and will select a value from the table con. Open() com = New OleDbCommand(” Select * from [inventory] where [UserName] = ‘” & TextBox1. Text & “‘ AND [Password] = ‘” & TextBox2. Text & “‘ “, con) reader = com. ExecuteReader ‘this code will read the table selected from its fields While reader. Read User = reader(0). ToString() & ” ” & reader(1). ToString() End While If reader. HasRows Then Me. Label7. Hide() Me. Label8. Hide() Me. Button3. Hide() Me. TextBox1. Enabled = False Me. TextBox2. Enabled = False Me. Button1. Enabled = False successful. Show() TextBox1. Clear() ComboBox1. Text = “” TextBox2. Clear() Me. Label4. Hide() Else TextBox2. Clear() Label7. Show() End If reader. Close() con. Close() ElseIf ComboBox1. Text = ” Faculty” Then con. Open() com = New OleDbCommand(” Select * from [faculty] where [username] = ‘” & TextBox1. Text & “‘ AND [password] = ‘” & TextBox2. Text & “‘ “, con) reader = com. ExecuteReader While reader. Read User = reader(0). ToString() & ” ” & reader(1). ToString() End While If reader. HasRows Then Me. Label4. Hide() Me. Label7. Hide() Me. Label8. Hide() Me. Button3. Hide() Me. TextBox1. Enabled = False Me. TextBox2. Enabled = False Me. Button1. Enabled = False successful1. show() TextBox1. Clear() ComboBox1. Text = “” TextBox2. Clear() Else Label7. Show() End If reader. Close() con. Close() Else Label7. Show() End If reader. Close() con. Close() Catch ex As Exception MsgBox(” ERROR: ” & ex. Message, MsgBoxStyle. Critical) End Try End Sub Private Sub Timer1_Tick(ByVal sender As System. Object, ByVal e As System. EventArgs) Handles Timer1. Tick ‘this line of code is to get the current time of the day Label3. Text = TimeOfDay End Sub Private Sub Button2_Click(ByVal sender As System. Object, ByVal e As System. EventArgs) Handles Button2. Click Button2. Hide() Me. Label8. Show() Me. Button3. Show() End Sub Private Sub Button3_Click(ByVal sender As System. Object, ByVal e As System. EventArgs) Handles Button3. Click ‘this codes will hide a label and a button Me. Label8. Hide() Me. Button3. Hide() Button2. Show()
This work, titled "Imports system.data.oledb" was written and willingly shared by a fellow student. This sample can be utilized as a research and reference resource to aid in the writing of your own work. Any use of the work that does not include an appropriate citation is banned.
If you are the owner of this work and don’t want it to be published on AssignBuster, request its removal.
Request RemovalReferences
AssignBuster. (2021) 'Imports system.data.oledb'. 20 December.
Reference
AssignBuster. (2021, December 20). Imports system.data.oledb. Retrieved from https://assignbuster.com/imports-systemdataoledb/
References
AssignBuster. 2021. "Imports system.data.oledb." December 20, 2021. https://assignbuster.com/imports-systemdataoledb/.
1. AssignBuster. "Imports system.data.oledb." December 20, 2021. https://assignbuster.com/imports-systemdataoledb/.
Bibliography
AssignBuster. "Imports system.data.oledb." December 20, 2021. https://assignbuster.com/imports-systemdataoledb/.
Work Cited
"Imports system.data.oledb." AssignBuster, 20 Dec. 2021, assignbuster.com/imports-systemdataoledb/.
Please, let us know if you have any ideas on improving Imports system.data.oledb, or our service. We will be happy to hear what you think: [email protected]