Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9320227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:35:04+00:00 2026-06-19T03:35:04+00:00

I have troubles preparing a query with 2 parameters in VB.NET . This is

  • 0

I have troubles preparing a query with 2 parameters in VB.NET.

This is my 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 > 0 Then
                    valid = True
                End If
            End Using
        Catch ex As Exception
            errorLabel.Text = DirectCast(GetLocalResourceObject("erroreDB"), String) & ": " & ex.ToString
        End Try

But, by doing this my valid value is always “false”, so it fails the row count.
I used some debug and looks like my table login inside ds is empty.
Query works, I tried it manually in SQLServer replacing parameters and I can’t understand why I have empty results.

What I’m doing wrong?.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:35:05+00:00Added an answer on June 19, 2026 at 3:35 am

    You don’t need to wrap your parameters in single quotes, as the parameter system takes care of that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some troubles with positioning my label/password field. With this code they both
I have troubles understanding this code that detects duplicates in string. int checker =
I have troubles understanding gi.repository I use this contruction in my code from gi.repository
I've created this little code and have troubles to sum up the results of
This is my MVVM Code and I have troubles customizing the text of Update/Cancel
I'm playing with lagrest prime divisor and I have troubles with this code: lpd
This is my actual code, I have troubles related with the right visualization of
I have some troubles mapping a JSON Array to RestKit. This is what the
I have troubles with sending an array of ints over a socket. the code
I have troubles to understand the use of while($row = mysql_fetch_array($query)) to display some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.