title: Oledb connection SQL command
body: <pre><code>Private Sub Myconnection()
  
      con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" &amp; Application.StartupPath &amp; "\Users.accdb")
      con.Open()
  End Sub
  
  Private Sub Login_Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      Myconnection()
  End Sub
  
  Private Sub LoginButton_Click(sender As Object, e As EventArgs) Handles LoginButton.Click
      Dim userTable As New DataTable
      Myconnection()
      adapt = New OleDbDataAdapter("Select * From Registered Users Where User Name='" &amp; UserNameTextBox.Text &amp; "'And Password='" &amp; PasswordTextBox.Text &amp; "'", con)
      adapt.Fill(userTable)
  
      If userTable.Rows.Count &gt; 0 Then
          MsgBox("Login Succesful")
  
      Else
          MsgBox("User Name Or Password Is invalid")
      End If
  End Sub
  </code></pre>
  
  <p>When i run the above code, Currently i am getting this error "Additional information: Syntax error (missing operator) in query expression 'User Name='User'And Password='password''." how should i change my code to make it work</p>