Public cn As OleDbConnection Public cmd As New OleDbCommand Public dr As OleDbDataReader Public Sub open_connection1() ' Try cn = New OleDbConnection cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\etks.mdb;Persist Security Info=True;Jet OLEDB:Database Password=@tekibears07" cn.Open() cmd.Connection = cn ' Catch ex As Exception ' MessageBox.Show("An Error occured while trying to connect in a loacal database" + vbCrLf + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) ' End Try End Sub Private Sub btn_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ok.Click 'Try If Not txt_emp_name.Text = "" Then open_connection1() cmd.CommandText = "INSERT INTO attendance (emp_id, emp_name, department, position, dates) VALUES ('" & txt_emp_id.Text & "', '" & txt_emp_name.Text & "', '" & txt_department.Text & "', '" & txt_position.Text & "', '" & txt_attendance_date.Text & "')" cmd.ExecuteNonQuery() dr.Close() : cn.Close() MessageBox.Show("Saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information) Close() Else MessageBox.Show("Enter a valid id number.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information) End If 'Catch ex As Exception 'MessageBox.Show("An error occured while entering new attendance" + vbCrLf + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) ' End Try End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)