title: How to create a log history in VB.NET and saves it into mysql workbench database?
body: <p>I only know few knowledge about vb.net and I am trying to understand it as much as I can. I've tried the code below for login button to save the login date &amp; time, and it works. Yet, I'm not sure what code to input for logout button. Please help me about this, thankyou! :)</p>
  <pre><code>Private Sub Button1_LoggedIn(sender As Object, e As EventArgs) Handles Button1.Click
      Dim command As New MySqlCommand(&quot;SELECT `StudentId`, `Account Password` FROM `usersaccount` WHERE `StudentId` = @username AND `Account Password` = @password&quot;, connection)
      command.Parameters.Add(&quot;@username&quot;, MySqlDbType.VarChar).Value = Username.Text
      command.Parameters.Add(&quot;@password&quot;, MySqlDbType.VarChar).Value = Pass.Text
      Dim adapter As New MySqlDataAdapter(command)
      Dim table As New DataTable()
  
      adapter.Fill(table)
  
      If table.Rows.Count = 0 Then
  
          MessageBox.Show(&quot;Invalid Username Or Password&quot;)
  
      Else
  
          Using con As New MySqlConnection(&quot;server=localhost;username=root;password=;database=logsrecord&quot;),
                  cmd As New MySqlCommand(&quot;Insert into loghistory.logsrecord (Username, Date, LoggedIn) Values (@Username, @Date, @LoggedIn);&quot;, con)
              cmd.Parameters.Add(&quot;@Username&quot;, MySqlDbType.VarChar).Value = Username.Text
              cmd.Parameters.Add(&quot;@Date&quot;, MySqlDbType.VarChar).Value = DateTime.Now.ToString(&quot;MMM-dd-yyyy&quot;)
              cmd.Parameters.Add(&quot;@LoggedIn&quot;, MySqlDbType.VarChar).Value = TimeOfDay.ToString(&quot;hh:mm:ss&quot;)
              con.Open()
              cmd.ExecuteNonQuery()
          End Using
          Form3.Show()
          Me.Hide()
  
  
      End If
  
  End Sub
  </code></pre>