Click here to Skip to main content
13,556,130 members
Click here to Skip to main content
Add your own
alternative version


34 bookmarked
Posted 22 Dec 2003

QASharp V1.0 [Query Analyzer like tool for MSDE database]

, 22 Dec 2003
Rate this:
Please Sign up or sign in to vote.
This project is meant to provide a tool similar to query analyzer which can be used to execute queries, create tables and all other common database activities.

Sample Image - QASharp.jpg


The QASharp V.1.0 was developed for those using the MSDE (Microsoft Desktop Engine). This project is meant to provide a tool similar to Query Analyzer which can be used to execute queries, create tables and do all other common database activities. This is still in its first release and this is my first attempt at developing a utility entirely in C# and also my first article to Code Project. The code is not at all optimized. My purpose for the first release is to get a working tool.

All suggestions, apprehensions, criticisms are welcome.

Functionality Supported

  • Create new query
  • Save existing query
  • Open existing query
  • Execute queries

Configuration settings to be made

In order for the application to work, make the following changes in the app.config file in the keys listed below.

<?xml version="1.0" encoding="Windows-1252"?>
    <add key="server" value="(local)" /> 
    <add key ="database" value="master" />
          <add key="uid" value="sa"/>
          <add key="pwd" value=""/> 
ServerThe server to connect to.
DatabaseThe initial database to connect to.
UidUser ID


  • Select a database.
  • Create a new document by clicking on New.
  • Type in the query (for multiple queries, add a GO keyword after each query).
  • Press F5 to execute query or click on the Execute icon on the toolbar.

The Code

// Function name :     ExecuteQuery
// Parameters    :     none
// Return        :     none
// Calls         :     ExecuteQuery(string databaseName, string Query)
/* Purpose       :     Executes the query user has typed in the query 
private void ExecuteQuery()
    dbh.ERR_MSG = "";
    ErrorText = "";
    if (ds != null) 
        ds = new DataSet();
        arrQuery = null;
    foreach(string s1 in arrQuery)
        ErrorText += dbh.ERR_MSG + "\n";
    if (ErrorText.Trim() == "")
        sbMain.Panels[0].Text = "Query batch completed.";
        sbMain.Panels[0].Text = "Query batch completed with errors.";           

// Function name :     ExecuteQuery
// Parameters    :     (in string databaseName, in string query)
// Return        :     none
/* Purpose       :     Executes each query called from ExecuteQuery() 
private void ExecuteQuery(string dataBaseName , string query)
    DataTable dt;
    if (ds == null) 
        ds  = new DataSet("result");
    dt = dbh.ExecDT(query);
    if (dt != null)
    ((frmQueryWriter)this.ActiveMdiChild).dgResult.DataSource = ds;
// Function name :     AddToArray
// Parameters    :     (in string QueryText)
// Return        :     none
/* Purpose       :     Splits the query based on "go" delimeter and 
                       stores it in array [arrQuery]
                       This [arrQuery] is used in ExecuteQuery()
private void AddToArray(string QueryText)

    Regex r = new Regex("go",RegexOptions.IgnoreCase);
    arrQuery = r.Split(QueryText);


  • Error Handling -> Both at code level i.e. try-catch block and, in case of any incorrect SQL statement, a provision is to be made to display a user friendly error message.
  • Connect/Disconnect to multiple servers.


Revision History

  • 12-23-2003: Original article


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Rajesh Pillai
India India
Co Founder at TekAcademy Labs.

You may also be interested in...


Comments and Discussions

GeneralCool Pin
Trance Junkie19-Oct-05 3:58
memberTrance Junkie19-Oct-05 3:58 
GeneralRe: Cool Pin
Rajesh Pillai19-Oct-05 4:06
memberRajesh Pillai19-Oct-05 4:06 
GeneralRegex Change Pin
Michael Potter30-Dec-03 5:36
memberMichael Potter30-Dec-03 5:36 
GeneralRe: Regex Change Pin
Rajesh Pillai30-Dec-03 6:11
memberRajesh Pillai30-Dec-03 6:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180515.1 | Last Updated 23 Dec 2003
Article Copyright 2003 by Rajesh Pillai
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid