ADO.NET Database Explorer with Query Analyzer : Part 3


Introduction

This is the part three of the Article Database Explorer. This parts adds some more and valuable functionality to the application, like Query Analyzer which can be used to query the Database and get the result in the list view. 

Enhancements 

This application adds two more forms, one as a MDI Form and other for the Query Analyzer. In the previous application (part -II) , we have added just a list view to display the details of the table, stored procedures and view. In this part three the GUI interface is now with MDI and all other forms are MDI Child , the Database Explore form is never closed by any means same as SQL Server Enterprise Manager (When ever you try to close this it will automatically gets minimized, but remains open.). There are two additional main menus called as Tool and Windows, as this is now a MDI application so you will require windows menu for switching between forms, Tools menu has a sub menu called as Query Analyzer for Query Analyzer form to get Displayed. 

Technologies Used

ADO. NET Win Forms. The Query Analyzer is a very similar to SQL Server Query Analyzer in functionality as form the Screen Shot you can see that you can use this to get results from many queries in a single go. The notices able difference is that in SQL Server T-SQL you have to all ways write GO between two statement , here that is not required. Query Analyzer form contains a Rich Textbox control for writing the  Queries , a Tab Control , with List View on Tab page. When ever a multi query statement is  fired then automatically depending on the number of result set tab pages are added and the results are displayed for all the queries in different list view on different tab pages. The new feature of ADO. NET that is used in this application is ADOError. When ever we try to execute any SQL Statement we write whole the execution in try catch block. The ADOError of ADO.NET is all most same as in ADODB. We have to use the ADOException in the catch block to catch all the ADO.NET error that has occured in the Execution. The ADOException object consist of a errors collection and by enumarating this errors collection we can get the ADO Error. The only requirement for handling ADO Error is to catch that in try..catch block.

I have not used any more ADO.NEt object in this application, this application has enhanced functionality and uses very rich set of winform object and controls. To Execute the query from the Query Analyzer you have to press Control-E (same key as in SQL Server Query Analyzer) there is no button or menu to get this done.

How to run the application

To run the application  , download the code in zip format , extract it ,extracting the file will create the directory and copy the files on your hard disk. Open the solution file named as Database Explorer.sln (Assuming you have Visual Studio. NET Beta1).Once you open the Solution you will find four forms (DatabaseExplore.cs, login.cs, MainForm.cs, QueryAnalyzer.cs) and two classes AssemblyInfo.cs and CDatabase.cs AssesmblyInfo.cs is the file generated by Visual Studio. Run the application, you will se a MDI application with three menus File, tools and Windows out of which File and Windows are Enabled. Clicking the File will give you two sub menus as login and exit. Click login to proceed further with the application or exit to close the application any time. If you clicked the login then you will get the familiar login screen asking you to enter the information of user, database and server for SQL Server to use with application. After entering the proper information press ok, if the application is able to stablise the connection with your information , then you will get the Database Explorer Screen same as previous screen(Application part-II). You can browse the TreeView node and can see any detail by right clicking (respective context menu will popup) on any node below the Parent Node named as Tables, Views or Stored Proc  .The detail is display in ListView.

If you want to fire any query on the database then click the tool menu which have a sub menu named as Query Analyzer.Clicking on Query Analyzer displays a Form with two section one section for entering the Query and the lower section for displaying the result in the table format. Write any valid qury and press Control-E the query will get executed and the result is displayed in the lower section. If you have fired  multiple query then you can see the multiple result in the lower pane as in the Screen Shot above, namely as result1,result2...... by clicking on the respective result you can view the result.

Up Next
    Ebook Download
    View all
    Learn
    View all