Sql String formatter : SQL Utilities « Database ADO.net « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Collections Data Structure
3. Components
4. Database ADO.net
5. Development Class
6. Event
7. File Stream
8. GUI Windows Form
9. Language Basics
10. Network
11. Office
12. Regular Expressions
13. Services Event
14. Thread
15. Web Services
16. Windows
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
C# / C Sharp » Database ADO.net » SQL UtilitiesScreenshots 
Sql String formatter
Sql String formatter


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

    public class Form1 : System.Windows.Forms.Form
    {
      private System.Windows.Forms.RichTextBox rtfSql;
      private System.Windows.Forms.MainMenu mainMenu1;
      private System.Windows.Forms.MenuItem menuItem1;
      private System.Windows.Forms.MenuItem menuItemFormat;
      private System.Windows.Forms.MenuItem menuItem4;
      private System.Windows.Forms.MenuItem menuItemExit;

      private string[] mSqlKeyWords = new string[] {"select","from","where","in","between",
              "is","null","not","order by","asc","desc","insert","into","values","update"
              "set","delete","truncate","table","join","on","create","drop"};

      public Form1() {
         InitializeComponent();
      }

      private void InitializeComponent() {
         this.rtfSql = new System.Windows.Forms.RichTextBox();
         this.mainMenu1 = new System.Windows.Forms.MainMenu();
         this.menuItem1 = new System.Windows.Forms.MenuItem();
         this.menuItemFormat = new System.Windows.Forms.MenuItem();
         this.menuItem4 = new System.Windows.Forms.MenuItem();
         this.menuItemExit = new System.Windows.Forms.MenuItem();
         this.SuspendLayout();
         // 
         // rtfSql
         // 
         this.rtfSql.Dock = System.Windows.Forms.DockStyle.Top;
         this.rtfSql.Font = new System.Drawing.Font("Courier New"9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
         this.rtfSql.Location = new System.Drawing.Point(00);
         this.rtfSql.Name = "rtfSql";
         this.rtfSql.Size = new System.Drawing.Size(290290);
         this.rtfSql.TabIndex = 0;
         this.rtfSql.Text = "";
         // 
         // mainMenu1
         // 
         this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                                  this.menuItem1});
         // 
         // menuItem1
         // 
         this.menuItem1.Index = 0;
         this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                                  this.menuItemFormat,
                                                                                  this.menuItem4,
                                                                                  this.menuItemExit});
         this.menuItem1.Text = "&Actions";
         // 
         // menuItemFormat
         // 
         this.menuItemFormat.Index = 0;
         this.menuItemFormat.Shortcut = System.Windows.Forms.Shortcut.F12;
         this.menuItemFormat.Text = "&Format statements";
         this.menuItemFormat.Click += new System.EventHandler(this.menuItemFormat_Click);
         // 
         // menuItem4
         // 
         this.menuItem4.Index = 1;
         this.menuItem4.Text = "-";
         // 
         // menuItemExit
         // 
         this.menuItemExit.Index = 2;
         this.menuItemExit.Text = "E&xit";
         this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
         // 
         // frmSql
         // 
         this.AutoScaleBaseSize = new System.Drawing.Size(815);
         this.ClientSize = new System.Drawing.Size(300300);
         this.Controls.Add(this.rtfSql);
         this.Font = new System.Drawing.Font("Courier New"9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
         this.Menu = this.mainMenu1;
         this.Name = "frmSql";
         this.Text = "SQL Tool";
         this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
         this.ResumeLayout(false);

      }
      static void Main() {
            Application.Run(new Form1());
      }


      private void menuItemFormat_Click(object sender, System.EventArgs e)
      {
         for (int i = 0; i < 23; i++
         {
            int index = 0;
            while ( (index = rtfSql.Find(mSqlKeyWords[i],index,RichTextBoxFinds.WholeWord)) >= 0
            {
               index++;
               rtfSql.SelectionColor = Color.Blue;
               rtfSql.SelectedText = mSqlKeyWords[i].ToUpper();
            }
         }
      }

      private void menuItemExit_Click(object sender, System.EventArgs e)
      {
         Application.Exit()
      }
    }

           
       
Related examples in the same category
1. Sql toolsSql tools
w__w_w_.___ja___v___a_2s.__com_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.