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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:45:25+00:00 2026-05-11T16:45:25+00:00

I need to create a strongly typed dataset during run-time for the user preferred

  • 0

I need to create a strongly typed dataset during run-time for the user preferred target database. Visual studio has massive design time support for creating typed datasets. I need to automate the process of generating typed datasets for the target database at runtime.

It should create…

1.) XSD file.

2.) Typed dataset represnting the Database

3.) Typed wrappers for all database tables and columns within the tables.

4.) TableAdapters for each table.

So I need to generate the same typed dataset at runtime which is generally created while design time using Typed dataset designer of the Visual Studio.

  • 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-05-11T16:45:26+00:00Added an answer on May 11, 2026 at 4:45 pm

    I tend to agree with jcollum on this one, using a Typed Dataset at runtime is probably the wrong way to go. If on the other hand, you just want to be able to get structured data ( aka, a DataTable ) from a database at runtime, you could use reflection to create a TableAdapter from an arbitrary data result.

    var results = (from data in db.SomeTable select data).ToArray();
    DataTable dt = ObjectArrayToDataTable(results);
    // At this point you have a properly structure DataTable.
    
    // Here is your XSD, if absolutely needed.
    dt.WriteXMLSchema("c:\somepath\somefilename.xsd");
    
    private static System.Data.DataTable ObjectArrayToDataTable(object[] data)
    {
        System.Data.DataTable dt = new System.Data.DataTable();
        // if data is empty, return an empty table
        if (data.Length == 0) return dt;
    
        Type t = data[0].GetType();
        System.Reflection.PropertyInfo[] piList = t.GetProperties();
    
        foreach (System.Reflection.PropertyInfo p in piList)
        {
            dt.Columns.Add(new System.Data.DataColumn(p.Name, p.PropertyType));
        }
    
        object[] row = new object[piList.Length];
    
        foreach (object obj in data)
        {
            int i = 0;
            foreach (System.Reflection.PropertyInfo pi in piList)
            {
                row[i++] = pi.GetValue(obj, null);
            }
            dt.Rows.Add(row);
        }
    
        return dt;
    }
    

    You could apply the same principal to create a structured DataSet and easily create a DataAdapter to it.

    Or perhaps I am mis-reading your requirements.

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

Sidebar

Related Questions

i'm trying to create a strongly-typed view using Visual Studio 2008. I can right-click
I need to create a linked server to a DB2 database on a mainframe.
I have created a strongly typed dataset in the VS 2005 Dataset Designer. There
I'm working on a project in Visual Studio, and I want to create a
I'll explain my point: The best practice is to create views strongly typed with
Because I need to build a very strongly-typed & type-safed project for Asp.net MVC.
Typically you create a Vector (strongly typed array) specifying a data type like: new
I'm attempting to create a strongly-typed view based on a class from another assembly.
How would I create a strongly typed class at runtime (so to be able
I need create custom dialog and put JPanel into it. Is it possible?

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.