title: Vb.net with access database: How can you help me simplify these codes?
body: <p>this is my code:</p>
  
  <pre><code>    'Set up connection string
      Dim cnString As String
  
      cnString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=..\data\testingDB.mdb"
  
      Dim sqlQRY As String = "SELECT * " &amp; _
          "FROM   users " &amp; _
          "WHERE  firstName = '" &amp; TextBox1.Text &amp; "' " &amp; _
          "  AND  lastName  = '" &amp; TextBox2.Text &amp; "'"
  
      'Create connection
      Dim conn As OleDbConnection = New OleDbConnection(cnString)
  
      Try
          ' Open connection
          conn.Open()
  
          'create data adapter
          Dim da As OleDbDataAdapter = New OleDbDataAdapter(sqlQRY, conn)
  
          'create dataset
          Dim ds As DataSet = New DataSet
  
          'fill dataset
          da.Fill(ds, "user")
  
          'get data table
          Dim dt As DataTable = ds.Tables("user")
  
          'display data
          Dim row As DataRow
  
          If TextBox1.Text = dt.Rows(0).Item(1) And TextBox2.Text = dt.Rows(0).Item(2) And dt.Rows(0).Item(5) = 10 Then
              MsgBox("10")
          ElseIf TextBox1.Text = dt.Rows(0).Item(1) And TextBox2.Text = dt.Rows(0).Item(2) And dt.Rows(0).Item(5) = 9 Then
              MsgBox("9")
          ElseIf TextBox1.Text = dt.Rows(0).Item(1) And TextBox2.Text = dt.Rows(0).Item(2) Then
              MsgBox("SUCCESS")
          Else
              MsgBox("fail")
          End If
  
  
  
  
      Catch ex As OleDbException
          MsgBox("Error: " &amp; ex.ToString &amp; vbCrLf)
      Finally
          ' Close connection
          conn.Close()
      End Try
  </code></pre>
  
  <p>I'm trying it to make it simple with the same results. As you can see the if-else statements were messy but it works 100%. I do want the if-else statements to be simple and works the same as above.</p>