title: Login, Email and Password Validation not working correctly with SQL tables Vb
body: <p>what I've been trying to do is grab the username, password and email from my sql table and validate it through my login form on vb.net. So, when I type in the username, password, and email in the form it <em>should</em> tell me if the login was successful or not. However, Whenever I type in the username, password and email from the sql table I created (MembershipInfo) into my login form I keep getting the error &quot;Username, Password or Email is not correct, please try again&quot; even though I know the username, password and email are correct (currently looking at it). I've tried multiple videos on youtube and even some solutions on here as well as on other sites, but nothing works. Can someone please tell me what I'm doing wrong? Here is my vb code:</p>
  <pre><code>Imports System.Data
  
  Imports System.Data.SqlClient
  
  Public Class WebForm1
      Inherits System.Web.UI.Page
  
    Public Shared conS As String = &quot;Server= ; Database=Yourdatabase ;Trusted_Connection=Yes;&quot;
  
      Public Shared con As SqlConnection = New SqlConnection(conS)
  
      Protected Sub TextBox8_TextChanged(sender As Object, e As EventArgs) Handles TextBox8.TextChanged
  
      End Sub
  
      Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  
          Dim un, pw, em, dbUN, dbPW, dbEM As String
  
          un = TextBox7.Text
          pw = TextBox8.Text
          em = TextBox9.Text
  
          Dim cmdUN As New SqlCommand(&quot;Select UserName from MembershipInfo Where Username = @p1&quot;, con)
  
          With cmdUN.Parameters
              .Clear()
              .AddWithValue(&quot;@p1&quot;, un)
          End With
  
          Dim cmdPW As New SqlCommand(&quot;Select Pass from MembershipInfo Where UserName = @p1&quot;, con)
  
          With cmdPW.Parameters
              .Clear()
              .AddWithValue(&quot;@p1&quot;, un)
          End With
  
          Dim cmdEM As New SqlCommand(&quot;Select Email from MembershipInfo where UserName = @p1&quot;, con)
  
          With cmdEM.Parameters
              .Clear()
              .AddWithValue(&quot;@p1&quot;, un)
          End With
  
          Try
              If con.State = ConnectionState.Closed Then con.Open()
              dbUN = cmdUN.ExecuteScalar
              dbPW = cmdPW.ExecuteScalar
              dbEM = cmdEM.ExecuteScalar
          Catch ex As Exception
              Response.Write(ex.Message)
          Finally
              con.Close()
          End Try
  
          If un = dbUN And pw = dbPW And em = dbEM Then
              MsgBox(&quot;Login Sucessful&quot;, vbExclamation, &quot;Welcome&quot;)
          Else
              MsgBox(&quot;Username, Password or Email does not match, please try again&quot;, vbExclamation, &quot;Error&quot;)
          End If
  
      End Sub
  End Class
  </code></pre>
  <p>And here is my sql code (I don't know if its needed but its better to be cautious):</p>
  <pre><code>Create Table MembershipInfo
  (
  
  MembershipID INT NOT NULL PRIMARY KEY Identity(1,1),
  
  Firstname varchar(50) not null,
  
  Lastname varchar(50) not null,
  
  UserName char(50) not null,
  
  Pass char(50) not null,
  
  Email char(50) not null
  
  ); 
  
  INSERT INTO MembershipInfo VALUES
  
  ('Jaycie', 'Adams', 'Imtotiredforthis', 'Golden1@1', 'JAdams2@gmail.com'),
  
  ('Bret', 'Steidinger', 'HellowWord', 'Wowwzaa12@', 'Reynolds13@gmail.com'),
  
  ('Rebecca', 'Wong', 'SomethingSomething1@1', 'Outofideas11', 'ReWong34@gmail.com'),
  
  ('Ciel', 'Phantomhive', 'DownwiththeQeen1@1', 'FellintomytrapWaha22@', 'CielPhantom22@gmail.com'),
  
  ('Jane', 'Borden', 'TiredTM4@1', 'Justtakemypasswordalready@3', 'JBorden56@gmail.com');
  
  Select * from MembershipInfo;
  </code></pre>