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

  • Home
  • SEARCH
  • 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 7077711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:27:26+00:00 2026-05-28T06:27:26+00:00

May be a dirty question. Is there a simpler way in C# code to

  • 0

May be a dirty question. Is there a simpler way in C# code to get resultset of a SQL query similar to that of SSMS output window

Input should be accepting a SQL Statement as shown below

select * from table_1;

Ouput should be a text like that shown on SSMS output window.

Column1 Colum2
1       2
2       3
  • 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-28T06:27:27+00:00Added an answer on May 28, 2026 at 6:27 am

    If you would rather have a console application than deal with a WinForms or ASP.Net WebForms application, this tutorial will show you how to do it, step by step. You really need to get all the details there, but this will give you an idea of how it’s done in a key method:

    /// <summary>
    /// Read in all rows from the Dogs1 table and store them in a List.
    /// </summary>
    static void DisplayDogs()
    {
        List<Dog> dogs = new List<Dog>();
        using (SqlConnection con = new SqlConnection(
        ConsoleApplication1.Properties.Settings.Default.masterConnectionString))
        {
        con.Open();
    
        using (SqlCommand command = new SqlCommand("SELECT * FROM Dogs1", con))
        {
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
            int weight = reader.GetInt32(0);    // Weight int
            string name = reader.GetString(1);  // Name string
            string breed = reader.GetString(2); // Breed string
            dogs.Add(new Dog() { Weight = weight, Name = name, Breed = breed });
            }
        }
        }
        foreach (Dog dog in dogs)
        {
        Console.WriteLine(dog);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The spring framework documentation states: In the unlikely case that a test may 'dirty'
May I know what is the most efficient way to construct a date object
May I know what is the workaround to make this code passed, in Visual
I am currently writing a little bootstrap code for a service that can be
Consider an object used to store a collection of items, but that collection may
So, this question may be a little vague, but I have constant discussions about
I am creating a quick'n'dirty utility that will enable editing of data read sequentially
Suppose I have a library Common that may be used stand-alone, and is used
In Windows, that is. I think the answer to this question is that I
This may be a fairly simple question, but my goal here is to redirect

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.