title: Creating Command to Search Excel Database for Existing User (Using OleDb on Visual Basic with Windows Form)
body: <p>everybody! :)</p>
  
  <p>I am currently developing a sign-in program for my mentoring organization. I've been slowly teaching myself coding through Visual Basic, and so far have some progress with signing-in users. I am trying to determine how to input a command to search the Excel file I'm connected with for a user ID (OneCard ID) to see if a user already exists and doesn't need to register with the system. This is my code thus far:</p>
  
  <pre><code>Imports System.Data.OleDb
  Public Class Register
  
      Dim cn As New OleDbConnection
      Dim cm As New OleDbCommand
  
      Private Sub BtnSave_Click(sender As Object, e As EventArgs) Handles BtnSave.Click
  
          cn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source =C:\Users\mn582\source\repos\VBTest.xls;extended properties=excel 8.0;"
          cn.Open()
  
          With cm
              .Connection = cn
              .CommandText = "insert into [Register Data$]values('" &amp; OneCard.Text &amp; "','" &amp; FirstName.Text &amp; "','" &amp; LastName.Text &amp; "')"
              .ExecuteNonQuery()
  
          End With
          cn.Close()
          MessageBox.Show("Welcome, " &amp; FirstName.Text &amp; "!")
  
          OneCard.Text = String.Empty
          FirstName.Text = String.Empty
          LastName.Text = String.Empty
      End Sub
  
      Private Sub BtnClose_Click(sender As Object, e As EventArgs) Handles BtnClose.Click
          Close()
          LiabilityForm.Show()
  
      End Sub
  End Class
  </code></pre>
  
  <p>I would really appreciate any advice on how to create a command for finding existing user ID's. I've searched here and on other websites, and am not sure what to do.</p>
  
  <p>Thank you, everybody. :)</p>