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

  • SEARCH
  • Home
  • 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 7847305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:51:15+00:00 2026-06-02T17:51:15+00:00

I am using visual studios 2010, and I have added a database and connected

  • 0

I am using visual studios 2010, and I have added a database and connected to it with SQLdatasource. I’m creating a basic login. I want the user to enter the login, and when he tries to login, I want to interate through the database and check if the login name exists.
How would I select just one column from the database and iterate through it.

I guess the select SQL statement will be

SELECT userName from tblUser

where username is column and tblUser is the table

  • 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-02T17:51:17+00:00Added an answer on June 2, 2026 at 5:51 pm

    You got the SQL statement right, at the end your SQLDataSource will look something like this:

    <asp:SqlDataSource
              id="SqlDataSource1"
              runat="server"
              DataSourceMode="DataReader"
              ConnectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;"
              SelectCommand="SELECT userName from tblUser">
          </asp:SqlDataSource>
    

    Note: You may want to use a connection string located in your config file:

     ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
    

    Also, you could also try to execute this query without using a SQLDataSource since it sounds like you will not be binding the result to a control. For example:

    using (SqlConnection connection = new SqlConnection(
                   connectionString))
        {
            SqlCommand command = new SqlCommand(
                "SELECT userName from tblUser", connection);
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            try
            {
                while (reader.Read())
                {
                   // check if reader[0] has the name you are looking for
    
                }
            }
            finally
            {
                // Always call Close when done reading.
                reader.Close();
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Microsoft Access 2010 database(*). Now, using Visual Studio 2010, I want
I have a Visual Studio 2010 Database project, from which I want to generate
I have Visual Studio 2010, using c# and I want to add this web
(Using VS 2010 with a Visual Studio Installer project.) I have added a 'Checkboxes(A)'
I have a console application written using Visual Studio 2010 / C#. I added
I have compiled this using Visual Studio 2010 compiler and it has compiler error
i am using visual studio 2010. i have a three dimensional structure array which,
I have a asp.net website with c# code behind and using visual studio 2010.
For reference, I'm using Visual Studio 2010. I have a custom build step defined
I am using DotNet.Highcharts in conjunction with Visual Studio 2010. I have created an

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.