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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:11:59+00:00 2026-05-16T23:11:59+00:00

There are several queries to be performed which return the DataTable object. In order

  • 0

There are several queries to be performed which return the DataTable object. In order to speed up the development I created a private method which should return the dataset by taking the query string as an argument.

the method is the following:

private DataTable getDataTable(string query)
    {
        DataTable dt = new DataTable();
        SqlDataAdapter DA = new SqlDataAdapter(query, conn);
        try
        {
            iStatusIndicator.SetBusy(true);
            iStatusIndicator.SetStatus("executing query" + query);
            DA.Fill(dt);
        }
        catch (Exception ex)
        {
            ...
        }
        iStatusIndicator.SetBusy(false);
        iStatusIndicator.SetStatus("");
        return dt;
    }

the procedure doesn’t throw an exception but the DataTable dt is always null. I tried to run a query string directly in sql command prompt and it returns the data as expected so I don’t know what could be the problem.

I would be very thankful if anyone of you explained the cause, suggested a fix or a better method for returning DataTables by receiving query strings.

Thank you

  • 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-16T23:12:00+00:00Added an answer on May 16, 2026 at 11:12 pm
    private static DataSet SelectRows(DataSet dataset,
        string connectionString,string queryString) 
    {
        using (SqlConnection connection = 
            new SqlConnection(connectionString))
        {
            SqlDataAdapter adapter = new SqlDataAdapter();
            adapter.SelectCommand = new SqlCommand(
                queryString, connection);
            adapter.Fill(dataset);
            return dataset;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with some code. There are several queries whose effect is, if the
I have a .php file which has several queries in it. I want the
I have a sql statement that is a union of several queries which all
There is a complex query which generates a report. The query has several sub
I need to store a set of entities, of which there are several specialized
During the course of our application login there are several queries ran, all around
There are several threads on this here at SO but I didn't find one
There are several other questions about this topic that I have gone through, but
There are several variant questions on this on SO, but I did not find
There are several places on the internet that talk about having multy key dictionary

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.