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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:40:31+00:00 2026-06-10T16:40:31+00:00

whats wrong with this code ? i want populate all users in datagridview1 but

  • 0

whats wrong with this code ? i want populate all users in datagridview1 but datagirdview showing nothing .

private void button4_Click( object sender, EventArgs e )
{
    dataGridView1.AutoGenerateColumns = true;
    dataGridView1.DataSource = db.todosUsuario("select usuario from usuarios");
}

//DB class
public DataSet todosUsuario(string query)
{
    DataSet dt= new DataSet();
    try
    {
        MySqlConnection cnn = new MySqlConnection(MysqlConnect());
        cnn.Open();
        MySqlDataAdapter da = new MySqlDataAdapter(query, cnn);
        da.Fill(dt,"Usuario");
        cnn.Close();
    }
    catch(Exception ed)
    {
        MessageBox.Show(ed.ToString());
    }
    return dt;
}
  • 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-10T16:40:33+00:00Added an answer on June 10, 2026 at 4:40 pm

    You are binding the DataGridView to a DataSet.
    In a dataset there are multiple tables so you need to specify which table should be shown in the DataGrid using the DataMember property. (Yes also when you have only one in the tables collection)

    dataGridView1.AutoGenerateColumns = true; 
    DataSet ds = db.todosUsuario("select usuario from usuarios"); 
    dataGridView1.DataMember = ds.Tables[0].TableName;
    dataGridView1.DataSource = ds;
    

    You could change the code binding to a single table

    dataGridView1.DataSource = ds.Tables[0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whats wrong with this code? -(void) drawRect:(CGRect) rect { CGContextRef c = UIGraphicsGetCurrentContext(); if
This is small code. But I couldn't find whats wrong with it. In my
Can someone please tell me whats wrong with this code. I'm not getting complete
Can anyone help me figure out whats wrong with this piece of xaml code?
I use this code to populate a flexigrid but it does not work $(#GrdRoom).flexAddData(['1','2','3']);
I am trying to figure out why this code doesn't work.. All i want
what's wrong with this code in Google Chrome r = webkitIndexedDB.open(db_name,1); r.onsuccess = success_callback;
What's wrong with this code?: SolverContext sc = SolverContext.GetContext(); Model m = sc.CreateModel(); m.AddDecision(new
Can anyone tell me what's wrong with this code? class Dataset < ActiveRecord::Base has_many
Can anyone tell me what's wrong with this code? It's giving me an error

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.