title: Preparing a Query in VB.NET
body: <p>I have troubles preparing a query with 2 parameters in <strong>VB.NET</strong>.</p>
  
  <p>This is my code:</p>
  
  <pre><code>Dim username As String = loginUsername.Value
  Dim password As String = EncryptMD5standard(loginPassword.Value)
  Dim valid As Boolean = False
  Dim connectionString As String = ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString
          Dim queryString As String = "SELECT id, user_name, role FROM users WHERE user_name = '@user' AND paswd = '@pass'"
          Dim ds As New DataSet()
          Try
              Using connection As New SqlConnection(connectionString)
                  Dim command As New SqlCommand(queryString, connection)
                  connection.Open()
                  command.CommandText = queryString
                  command.Parameters.Add("@user", SqlDbType.NVarChar, 15).Value = username
                  command.Parameters.Add("@pass", SqlDbType.NVarChar, 32).Value = password
                  Dim adapter As New SqlDataAdapter()
                  adapter.SelectCommand = command
  
                  adapter.Fill(ds, "login")
                  If ds.Tables("login").Rows.Count &gt; 0 Then
                      valid = True
                  End If
              End Using
          Catch ex As Exception
              errorLabel.Text = DirectCast(GetLocalResourceObject("erroreDB"), String) &amp; ": " &amp; ex.ToString
          End Try
  </code></pre>
  
  <p>But, by doing this my <code>valid</code> value is always "false", so it fails the row count.
  I used some debug and looks like my table <code>login</code> inside <code>ds</code> is empty.
  Query works, I tried it manually in SQLServer replacing parameters and I can't understand why I have empty results.</p>
  
  <p>What I'm doing wrong?.</p>