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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:44:41+00:00 2026-05-18T01:44:41+00:00

I am porting a VB6 database-centric application relying on ADO to C# (relying on

  • 0

I am porting a VB6 database-centric application relying on ADO to C# (relying on ADO.NET). The schema of the databases this application access are arbitrary and I’m relying on DbConnection.GetSchema to retrieve information.

As near as I can tell (And here’s where I need help), GetSchema is supposed to replace the ADOX.Catalog. So here’s what I have (sorry about the formatting!):

List<string> temp = new List<string>();
string[] restrictions = new string[4] { null, null, tableName, null };
using (SqlConnection databaseConnection = new SqlConnection(connString))
{
    databaseConnection.Open();
    foreach (DataRow row in databaseConnection.GetSchema(
                SqlClientMetaDataCollectionNames.Columns, restrictions).Rows)
    {
        temp.Add(row["COLUMN_NAME"] as string);
    }
}

I know for a fact that this correctly fills temp with the names of the columns for the table named tableName. However, the order seems arbitrary, whereas with ADOX.Catalog the order is exactly the same as you’d find it in Sql Management Studio. Here’s how the original does it:

Dim cat As New ADOX.Catalog
Dim T As ADOX.Table
Dim C As ADOX.Column

Set cat.ActiveConnection = conn

'retrieve list of fields for this table'
Set T = cat.Tables(tableName)

For Each C In T.Columns
    temp.Add C.Name

Next

They come out in different orders, and I’m not sure what to do about it!

My question is basically: Does ADO.NET have a replacement for ADOX.Catalog other than GetSchema? If it doesn’t how can I order GetSchema so that I don’t get random ordering (it’s going to confuse my co-workers who are using this so badly!)

  • 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-18T01:44:42+00:00Added an answer on May 18, 2026 at 1:44 am

    You can use the DataTable.Select method to order the results:

    databaseConnection.Open();
    DataTable columns = databaseConnection.GetSchema(
                SqlClientMetaDataCollectionNames.Columns, restrictions);
    foreach (DataRow row in columns.Select("", "COLUMN_NAME"))
    {
        temp.Add(row["COLUMN_NAME"] as string);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm porting an application from VB6 to VB.NET and have come across something that
I am working on porting a VB6 application to .NET and one of the
I will likely be responsible for porting a vb6 application to c#. This application
I'm working on porting a large vb6 application to .NET. The current app is
Porting an application from C# (1.1 framework) to VB.NET (3.5 framework), and I have
I am working on porting a VB6 application to C# (Winforms 3.5) and while
Hopefully I can articulate this well: I'm porting an application I made years ago
I am just porting a project from VB6 to VB.NET with the help of
I'm porting an old VB6 app into .Net but one Vb6 form is too
I am porting a .NET application that works in .NET 3.5+ to WinRT, and

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.