title: SELECT UPDATE SQL Not Working
body: <p>I have 2 forms </p>
  
  <p>First Form has </p>
  
  <pre><code>Public Class frmMain
  
  Friend strBillIDNumber As String
  Friend strBillPassword As String
  Friend ds As New DataSet
  Friend cnn As OleDbConnection
  Friend sql As String
  Friend adptr As OleDbDataAdapter
  Dim attempt As Integer = 1
  
  Private Sub btnSign_Click(sender As Object, e As EventArgs) Handles btnSign.Click
  
      Dim connectionString As String
      connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Renz\Documents\Visual Studio 2012\FINAL\Database\UsersDB.accdb;"
      sql = "Select ID, LASTNAME, FIRSTNAME, LOGINSTATUS from TblUser"
      cnn = New OleDbConnection(connectionString)
      Try
          cnn.Open()
          adptr = New OleDbDataAdapter(sql, cnn)
          adptr.Fill(ds)
  
  
  
          For i = 0 To ds.Tables(0).Rows.Count - 1
  
              If ds.Tables(0).Rows(i).Item(0) = txtID.Text Then
                  MessageBox.Show("UserName Matched")
                  If ds.Tables(0).Rows(i).Item(1) = txtPassword.Text Then
                      MessageBox.Show("Password Matched")
  
                      If txtPassword.Text = "admin" Then
                          MessageBox.Show("You are now Logged In as Admin.")
                          frmFaculty.Show()
                          Me.Hide()
                      Else
                          frmStudent.lblSI.Text = ds.Tables(0).Rows(i).Item(0)
                          frmStudent.lblLN.Text = ds.Tables(0).Rows(i).Item(1)
                          frmStudent.lblFN.Text = ds.Tables(0).Rows(i).Item(2)
                          frmStudent.lblLS.Text = ds.Tables(0).Rows(i).Item(3)
                          MessageBox.Show("You are now Logged In.")
                          frmStudent.Show()
                          Me.Hide()
                      End If
                  Else
                      MessageBox.Show("Invalid Password.")
                      MessageBox.Show("Please Try Again." &amp; vbNewLine &amp; "ATTEMPT: " &amp; attempt &amp; " out of 3")
                      attempt = attempt + 1
                  End If
              End If
  
          Next
  
          adptr.Dispose()
          cnn.Close()
      Catch ex As Exception
          MessageBox.Show("Please Try Again!")
      End Try
  
      'log-in attempt 3x fail'
      If attempt &gt; 3 Then
          MessageBox.Show("You have exceeded the number of login attempt." &amp; vbNewLine &amp; "Please Contact the Administrator.")
      End If
  End Sub
  </code></pre>
  
  <p>And my Second Form Has </p>
  
  <pre><code>Imports System.Data.OleDb
  
  Public Class frmStudent
  Dim TimeInHold As String
  Private Sub loginBTN_Click(sender As Object, e As EventArgs) Handles loginBTN.Click
  
      Dim cnn2 As New OleDbConnection
      Dim Command As OleDbCommand
      Dim i As Integer
      Dim sql2 As String
      Dim status As String
  
      Try
          cnn2 = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Renz\Documents\Visual Studio 2012\FINAL\Database\AuditDB.mdb;")
          cnn2.Open()
  
          sql2 = "INSERT INTO Audit ([ID],[TIMEIN]) VALUES('" &amp; frmMain.txtID.Text &amp; "','" &amp; DateTime.Now &amp; "')"
  
          Command = New OleDbCommand(sql2, cnn2)
          i = Command.ExecuteNonQuery
  
      Catch ex As Exception
          cnn2.Close()
  
      End Try
  
      MessageBox.Show("You have successfully Signed in." &amp; vbNewLine &amp; " Please Don't Forget to Logout.")
      frmMain.cnn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Renz\Documents\Visual Studio 2012\FINAL\Database\UsersDB.accdb;")
      frmMain.cnn.Open()
      frmMain.adptr = New OleDbDataAdapter(frmMain.sql, frmMain.cnn)
      frmMain.adptr.Fill(frmMain.ds)
      If frmMain.ds.Tables(0).Rows(i).Item(0) = lblSI.Text Then
          frmMain.sql = "UPDATE TblUser SET LOGINSTATUS = 'SignedIn'"
  
          frmMain.cnn.Close()
      End If
      Me.Close()
      frmMain.Show()
      frmMain.txtID.Text = String.Empty
      frmMain.txtPassword.Text = String.Empty
  End Sub
  </code></pre>
  
  <p>I can't get my SELECT and UPDATE sql statement to work that will get the data set from form 1.  And when the button is clicked, it will update the field "LoginStatus" to a value of "Signed In".</p>
  
  <p>P.S. I'm creating a time-in, time-out monitoring system that will determine if the user is an admin or a student and will redirect them to their corresponding forms.  Student form will have sign in and sign out buttons, and will record their time in and time out.  When sign in is clicked, it will be grayed out.</p>
  
  <p>Please Help..</p>