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.
- 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.
<add key="server" value="(local)" />
<add key ="database" value="master" />
<add key="uid" value="sa"/>
<add key="pwd" value=""/>
|The server to connect to.|
|The initial database to connect to.|
- 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.
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.Text = "Query batch completed.";
sbMain.Panels.Text = "Query batch completed with errors.";
private void ExecuteQuery(string dataBaseName , string query)
if (ds == null)
ds = new DataSet("result");
dt = dbh.ExecDT(query);
if (dt != null)
((frmQueryWriter)this.ActiveMdiChild).dgResult.DataSource = ds;
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.
- 12-23-2003: Original article
Principal Consultant and Chief Architect as Megasoft Informations Systems Pvt. Ltd.
My community website: http://ownabook.org