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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:52:33+00:00 2026-05-18T03:52:33+00:00

I am making a SQL script editor / executor component for my application, very

  • 0

I am making a SQL script editor / executor component for my application, very similar in nature to the SQL Server Management Studio or ye old Query Analyzer. I’m using C#, .NET Framework 3.5 SP1. My issue is that I would like to have the component parse the SQL to determine whether it should use SqlCommand.ExecuteNonQuery(), SqlCommand.ExecuteScalar(), or SqlDataAdapter.Fill(dataTable) to run the script. The purpose is to allow the user to execute non-queries but also return result sets for the user to view, just like the SSMS / Query Analyzer would do, but also hide the ADO.NET implementation details from them.

I would normally default to SqlDataAdapter.Fill(dataTable) and always return the DataTable for the user to view. This would still run non-queries as ExecuteNonQuery would do, but it has the overhead of using the slower SqlDataAdapter class to run things. This is not optimal in many non-query situations.

The approach I’ve taken is to allow the user to select the result type, either ‘Table’ (which will run SqlDataAdapter.Fill(…), ‘Value’ (which will run ExecuteScalar), or ‘None’ (which will run ExecuteNonQuery). But I don’t want them to be exposed to the ADO.NET implementation details. I want them to just type a SQL script in a text box, hit an Execute button, and the program will run the script and return a result set in a datagrid if there is one.

So… I need the component to be able to parse the SQL before executing it, to discern whether there will be a result set from running the script or not.

  • 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-18T03:52:34+00:00Added an answer on May 18, 2026 at 3:52 am

    Yo don’t parse the text, since you don’t have the information necessary in the client to determine if the requests would return a result. Take a requests like execute usp_anonymousProcedure 1,2;, can you tell if it returns a result or not? Obviously, not. So you send the request to the server and ask it to just return the metadata about the result:

    SET FMTONLY ON;
    

    Returns only metadata to the client.
    Can be used to test the format of the
    response without actually running the
    query.

    You set this on, run request your request on the server, then you’ll know the shape of the result returned by the request.

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

Sidebar

Related Questions

No related questions found

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.