Blue Theme Orange Theme Green Theme Red Theme
 
MindFusion's Components
Home | Forums | Videos | Photos | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
World Class ASP.NET Hosting – Click Here for 3 Months Free/NO Setup Fee!
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » Threading » Enhanced Oracle Explorer in C# and .NET using Windows Forms

Enhanced Oracle Explorer in C# and .NET using Windows Forms

This application will allows to do multiple simple activities on oracle database like running select statements and getting selected procedure's definition simultaneously in a thread-based GUI.

Author Rank:
Total page views :  16828
Total downloads :  559
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
DBExplorer.zip
 
Become a Sponsor

Oracle is commonly using database as a backend for .NET applications. But, the main problem with oracle is, there is no in-built easy-to-use GUI for accessing objects in it. So the only option is to use third party tools like TOAD or PL/SQL Developer for accessing objects without writing queries for activities like getting all tables, procedures, functions and their definition etc...


But, it's not possible to get license for those tools for small projects. Even if you get license for them, it is very hard to open these tools for small activities (like getting all tables, procedure's definition and for running simple select statements...). These tools takes more time to start, consumes more resources and its not based on threads. So, we can't do multiple operations in these tools at a time like getting procedure's definition and executing a query simultaneously. By using this application we are just a click away from accessing those database objects. I will explain the features present in it followed by design and coding.

 

I designed this application using C#, VS.NET 2003 and Windows Forms.
 

Following are the features present in this Application:

  • Easy access to Tables, Procedures and Functions.
  • Entirely based on threads.
  • We can do multiple activities simultaneously.
  • Ability to export table data to xml file.
  • Less startup time when compared to TOAD.
  • Executes any select statements without blocking user from doing other 
    operations in application.
  • Ability to cancel any thread at any point of time.
  • Ability to maintain list of recent queries executed in application.
  • Shows objects which are accessible to current login account.

Create a new Windows Application in C# and name it as DBExplorer.

Then rename Form1 to frmlogin and add following controls shown in below figure:



Figure 1.

Here, I am using OLEDB Data Provider and tnsnames file to connect to Oracle Database. We can use ODP.NET Data Provider to improve performance of this application. On clicking Login button, I am creating a connection using username, password and data source will be in this format: 

(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = <host-name>)(PORT = 1000)))(CONNECT_DATA =(SID  = dbname)));

 

I am getting this data source string from my tnsnames.ora file. After creating connection, I am closing this login form and opening new form named frmdbexplorer to explore oracle objects.

 

Now, add a new form to solution and name it as frmdbexplorer and design it as shown below:



Figure 2.

I will explain each control present in this form followed by its purpose:

 

I designed MainMenu with following menuitems:

View Objects of -> ALL [MINE] -> Tables -> Full Details (will load table name, its row count, column name and its size, type and default value into TreeView).                      

  • Partial Details (will load just table name and its row count into TreeView).
  • Procedures (Loads all Procedure names into Dropdown).
  • Functions (Loads all Functions into Dropdown). 

Before explaining this menuitems, I have to explain little bit about Data Dictionary in Oracle.

 

Data Dictionary is a set of tables containing information about all objects like tables, views, PL/SQL Procedures, triggers created by each user.


For example, USER_TABLES contains all tables that belong to current login account. Similarly, ALL_TABLES contains tables that you can through your account and DBA_TABLES contains tables that are accessible to user having DBA privileges.

 

Normally in oracle, objects are classified as:

  • Objects accessible to you (tables starting with USER_)
  • Objects accessible to all account (tables starting with ALL_)
  • Objects accessible to DBA (tables starting with DBA_) 

So by clicking proper menuitem we can get objects of your choice.

 

Execute Query will just execute select statement written in textbox of Execute Query tabpage and returns the result in a dataset. Finally, this dataset is binded to DataGrid Control to display results of Query.

 

Export to XML will export selected Table's data into an xml file and displays it in IE.

 

Recent Queries will maintain the list of queries executed by you in application. So, we no need to rewrite any query, which is written already once.

 

Cancel Current -> Loading Tables will stop the thread that is loading all tables in Treeview.

Cancel Current -> Loading Objects will stop the thread that is loading all procedures and functions into DropDownlist.

 

In left side of the form, there is a Treeview control which will load all tables. Next to it, there is a tab control having two tab pages. One tab page (Selected Item Defn) will load selected function/procedure definition into textbox and another tab page (Execute Query) will execute the query written in textbox and displays its result in datagrid control present below the textbox.

 

The main logic behind this application is, whenever you select an operation like executing a time-consuming query, we will just create a separate thread to handle that operation. We can continue with doing another operation like loading all tables belonging to your account simultaneously. So we can do multiple tasks at a time, which is not possible in TOAD.

 

All the controls present in this form are created by main thread. So, it's not possible for the other threads to update those controls. Inorder to achieve this we are using Invoke() method along with delegates.

 

I am using following queries to get objects from database:

 

Select table_name from +type +_tables
Select distinct name from +type +_source where type like 'PROCEDURE'

 

where type can be of USER_ or ALL_ for getting list of tables and its properties.
 

So, final output will be like this:

 



Figure 3.

We can still enhance this application by including access to other database objects like sequences, indexes....

I am attaching code to this for further reference. I hope this code will be useful for all.


Login to add your contents and source code to this article
 About the author
 
Sateesh Arveti
I hold Bachelors degree in Computer Science along with MCSD,MCTS and MVP for the year 2009. Areas of Interest: C#, WPF, WF, silverlight, ASP.NET, Oracle and SQL Server.

Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010 Professional
Microsoft Visual Studio 2010 Professional will launch on April 12, but you can beat the rush and secure your copy today by pre-ordering at the affordable estimated retail price of $549 (US). Pre-order now.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Developer-Ready ASP.NET 2.0 Web Hosting with 3 MONTHS FREE
Now supporting .NET 3.0 Framework with Windows Workflow Foundation, Windows Communication Foundation (WCF), Windows Presentation Foundation (WPF), windows CardSpace (WCS)! Providing more flexibility for Developers with Web Services Support and a User/Permission Manger. Also supporting MS SQL 2005/2000 with Real-Time Backups, FREE Automated Attach .MDF Tool, FREE SQL Restore and Shrink SQL DB Tools, and SQL
 
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
DBExplorer.zip
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
Become a Sponsor
 Comments
How in SQL Server by Fransiscus On May 7, 2007
Is there any chances to do exploring database for SQL Server 2000 using C# like what you explain in this section? If can, please help me to develop it....
Reply | Email | Delete | Modify | 
Re: How in SQL Server by Sateesh On May 10, 2007
Hi, We can do this same kind of application for SQL Server also.But,for SQL Server there is inbuilt UI(Enterprise Manager) which is very easy to use.So,I think its not worthy to design this kind of applications for SQL Server.But,Still if you want to design for SQL Server,plz provide what kind of help u r expecting from me...
Reply | Email | Delete | Modify | 
SQL Developer by tony On August 7, 2007
I've found SQL Developer to be a decent alternative to Query Analyzer. It's now available from Oracle for free.
Reply | Email | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2009.6.2
 © 2010  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.