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 8951315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:38:05+00:00 2026-06-15T13:38:05+00:00

For example i have a database called dbuser: username: teste password: xxxx isonline: 1

  • 0

For example i have a database called dbuser:

username: teste
password: xxxx
isonline: 1

username: teste2
password: xxxx
isonline: 1

I thought that this query:

"SELECT username FROM dbuser  WHERE (isonline ='1')"

would return both teste and teste2, but when i ask the result for example in a MessageBox, with both teste and teste2 online, it only shows teste, but when i close the teste connection then it appears teste2 in the MessageBox. Im guessing its only returning the first row to me, so how can i get all the values?

This is the method code:

public static string GetOnline() 
{ 
  string listaOnline; 
  listaOnline = ExecuteQuery("SELECT * username FROM dbuser WHERE (isonline ='1')").ToString();
  return listaOnline;
} 

and I show it as MessageBox.Show(DbManager.GetOnline());

  • 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-15T13:38:06+00:00Added an answer on June 15, 2026 at 1:38 pm

    This should give you a list of strings that you want in the fastest manner. reader.GetString(0) means that you take a sting value from column with index 0 (so the first one).

    List<string> result = new List<string>();
    
    using (SqlConnection connection = new SqlConnection(databaseConnectionString))
    {
      connection.Open();
      using (SqlCommand command = new SqlCommand(query, connection))
      {
        command.CommandType = CommandType.Text;
        using (SqlDataReader reader = command.ExecuteReader())
        {
          while (reader.Read())
          {
            result.Add(reader.GetString(0));
          }
    
          reader.Close();
        }
        command.Cancel();
      }
    }
    
    return result;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example I have this gem called Authlogic-openid, that plugin is outdated, no longer
I have a database that contains a history of product sales. For example the
In this example we have 3 related tables on a SQLite database: CREATE TABLE
I have an xml database that contains films, for example: <film id=5> <title>The Avengers</title>
Example: I have two tables in my database called classA and classB , and
I have a database table called posts that has 'id, title, slug and content'
I have a database table called settings, and in that table I've got 2
This question can best be asked by example. Say I have a database table
We have a database called AVL in SQL Server 2008 R2 SE. This database
I have a table in my MySQL database called Sponsors . This table has

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.