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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:22:48+00:00 2026-06-08T13:22:48+00:00

I am using WPF data binding to a dataset to display the contents of

  • 0

I am using WPF data binding to a dataset to display the contents of a table.
The SELECT statement can return no records and the datatable will not get any metadata from this. Then the WPF DataGrid is minimised with no columns.
I know it is possible to specifically query the metadata of the table but I am checking if there is a shorthand method.

If the query is empty how do I still get the column information?

People like to see code so here it is
Currently I have:

<DataGrid AutoGenerateColumns="True" EnableRowVirtualization="True" 
    ItemsSource="{Binding Path=SelectedUserTable, Mode=TwoWay}"  Name="userTablesContentGrid"
    RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Stretch">            
</DataGrid>

In my ViewModel. DisplayUserTable is called to load the SelectedUserTable property

public void DisplayUserTable(string tableName)
{
    if (!UserTablesDataSet.Tables.Contains(tableName))
    {
        FillTable(tableName);
    }
    SelectedUserTable = UserTablesDataSet.Tables[tableName];
    InvokePropertyChanged("SelectedUserTable");
}

private void FillTable(string tableName)
{
    UserTablesDataAdapter.SelectCommand = new SqlCommand(string.Format("SELECT * FROM [{0}]", tableName), _conn);
    UserTablesDataAdapter.Fill(UserTablesDataSet, tableName);
}
  • 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-08T13:22:49+00:00Added an answer on June 8, 2026 at 1:22 pm

    Issue the DataAdapter.FillSchema command.

    UserTablesDataAdapter.FillSchema(UserTablesDataSet, SchemaType.Mapped);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to do data binding in WPF on a data grid using
I am using WPF datagrid. Data I am binding to the grid is not
I have a situation where I am using wpf data binding and validation using
I have a very simple WPF application in which I am using data binding
I'm using WPF. On my window there is a data grid which binding with
I have just started using WPF and am having trouble data binding from the
How do you Clear/Remove DataBinding in Silverlight? similar to: Remove binding in WPF using
I have a WPF Application using Fluent NHibernate 1.0 RTM and System.Data.SQLite 1.0.65 that
Using the MVVM pattern creating WPF applications you have the ViewModel providing data to
I am using System.Data.SQLite to store my program's data and settings (in a WPF

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.