Bootstrap

用DotNet开发MySql和SqlServer的简单客户端

用的外部控件:DotNetMagic,SyntaxEditor(ActiproSoftware)

代码如下

Form1.cs

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using Crownwood.DotNetMagic.Common;
using Crownwood.DotNetMagic.Controls;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using ActiproSoftware.Drawing;
using ActiproSoftware.SyntaxEditor;
namespace dbTool
{
 /// <summary>
 /// Form1 的摘要说明。
 /// </summary>
 public class DBForm : System.Windows.Forms.Form
 {
  private Crownwood.DotNetMagic.Menus.MenuCommand ConnectCMD;
  private Crownwood.DotNetMagic.Controls.StatusBarControl DBStatus;
  private System.Data.SqlClient.SqlDataAdapter SQLDataAdapter;
  private System.Data.DataSet myDataSet;
  private Crownwood.DotNetMagic.Menus.MenuControl MainMenu;
  private Crownwood.DotNetMagic.Menus.MenuCommand FileCMD;
  private Crownwood.DotNetMagic.Controls.ToolControl DBToolControl;
  private System.Windows.Forms.Panel LeftPanel;
  private Crownwood.DotNetMagic.Controls.Command.ButtonCommand ConnectButton;
  private System.ComponentModel.IContainer components;
  private System.Data.DataSet ResultSet;


  /// <summary>
  /// User Data
  /// </summary>
  private System.Data.SqlClient.SqlConnection myConnection;
  private String Server;
  private int Port;
  private String UserName;
  private String Password;
  private int ConnectedTime;
  private int CommandTime;
  private Crownwood.DotNetMagic.Menus.MenuCommand DisConncetCMD;
  private Crownwood.DotNetMagic.Controls.TabControl DBTab;
  private Crownwood.DotNetMagic.Controls.TabPage Attribute;
  private Crownwood.DotNetMagic.Controls.TabPage Broswer;
  private Crownwood.DotNetMagic.Controls.TabPage Query;
  private System.Windows.Forms.Splitter DBSplitter;
  private System.Windows.Forms.DataGrid QueryGrid;
  private Crownwood.DotNetMagic.Controls.TreeControl DBTree;
  private String DataBase=null;
  private System.Windows.Forms.ImageList DBImage;
  private String CMDStr="";
  private System.Data.SqlClient.SqlCommandBuilder myBuilder;
  private Crownwood.DotNetMagic.Controls.Command.ButtonCommand DisConnectButton;
  private Crownwood.DotNetMagic.Controls.Command.ButtonCommand UpdataCMDButton;
  private Crownwood.DotNetMagic.Controls.ToolControl QueryTool;
  private Crownwood.DotNetMagic.Controls.Command.ButtonCommand ExecuteButton;
  private String CurrentBrowser;
  private System.Windows.Forms.Panel BrowserPanel;
  private System.Windows.Forms.Splitter MainSplitter;
  private Crownwood.DotNetMagic.Controls.Command.ButtonCommand UpdateCancelButton;
  private Crownwood.DotNetMagic.Controls.Command.ButtonCommand RefreshButton;
  private String CurrentQuery;
  private Crownwood.DotNetMagic.Controls.Command.ButtonCommand UpdateCannel;
  private Crownwood.DotNetMagic.Controls.Command.ButtonCommand QueryRefresh;
  private Crownwood.DotNetMagic.Menus.MenuCommand HelpCMD;
  private System.Windows.Forms.DataGrid DBAttibute;
  private System.Windows.Forms.DataGrid DBGrid;
  private System.Windows.Forms.Panel panel1;
  private Crownwood.DotNetMagic.Controls.ToolControl DBBrowserTool;
  private System.Windows.Forms.TextBox ItemCount;
  private Crownwood.DotNetMagic.Controls.ButtonWithStyle ModifyButton;

  private String LastBrowserSql;
  private String LastBrowserTable;
  private System.Windows.Forms.ImageList IconsImage;
  private Crownwood.DotNetMagic.Controls.StatusPanel TimePannel;
  private Crownwood.DotNetMagic.Controls.StatusPanel ItemPanel;
  private Crownwood.DotNetMagic.Controls.Command.ButtonCommand LoadButton;
  private System.Windows.Forms.OpenFileDialog OpenSQLDialog;
  private ActiproSoftware.SyntaxEditor.SyntaxEditor DBQuery;
  private int CountofItem=1000;
  public DBForm()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   this.components = new System.ComponentModel.Container();
   System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(DBForm));
   ActiproSoftware.SyntaxEditor.Document document1 = new ActiproSoftware.SyntaxEditor.Document();
   this.ConnectCMD = new Crownwood.DotNetMagic.Menus.MenuCommand();
   this.DBStatus = new Crownwood.DotNetMagic.Controls.StatusBarControl();
   this.TimePannel = new Crownwood.DotNetMagic.Controls.StatusPanel();
   this.ItemPanel = new Crownwood.DotNetMagic.Controls.StatusPanel();
   this.myDataSet = new System.Data.DataSet();
   this.ConnectButton = new Crownwood.DotNetMagic.Controls.Command.ButtonCommand();
   this.MainMenu = new Crownwood.DotNetMagic.Menus.MenuControl();
   this.FileCMD = new Crownwood.DotNetMagic.Menus.MenuCommand();
   this.DisConncetCMD = new Crownwood.DotNetMagic.Menus.MenuCommand();
   this.HelpCMD = new Crownwood.DotNetMagic.Menus.MenuCommand();
   this.DBToolControl = new Crownwood.DotNetMagic.Controls.ToolControl();
   this.DisConnectButton = new Crownwood.DotNetMagic.Controls.Command.ButtonCommand();
   this.LeftPanel = new System.Windows.Forms.Panel();
   this.MainSplitter = new System.Windows.Forms.Splitter();
   this.DBTab = new Crownwood.DotNetMagic.Controls.TabControl();
   this.Attribute = new Crownwood.DotNetMagic.Controls.TabPage();
   this.DBAttibute = new System.Windows.Forms.DataGrid();
   this.Broswer = new Crownwood.DotNetMagic.Controls.TabPage();
   this.DBGrid = new System.Windows.Forms.DataGrid();
   this.BrowserPanel = new System.Windows.Forms.Panel();
   this.ModifyButton = new Crownwood.DotNetMagic.Controls.ButtonWithStyle();
   this.ItemCount = new System.Windows.Forms.TextBox();
   this.panel1 = new System.Windows.Forms.Panel();
   this.DBBrowserTool = new Crownwood.DotNetMagic.Controls.ToolControl();
   this.UpdataCMDButton = new Crownwood.DotNetMagic.Controls.Command.ButtonCommand();
   this.UpdateCancelButton = new Crownwood.DotNetMagic.Controls.Command.ButtonCommand();
   this.RefreshButton = new Crownwood.DotNetMagic.Controls.Command.ButtonCommand();
   this.Query = new Crownwood.DotNetMagic.Controls.TabPage();
   this.QueryTool = new Crownwood.DotNetMagic.Controls.ToolControl();
   this.ExecuteButton = new Crownwood.DotNetMagic.Controls.Command.ButtonCommand();
   this.UpdateCannel = new Crownwood.DotNetMagic.Controls.Command.ButtonCommand();
   this.QueryRefresh = new Crownwood.DotNetMagic.Controls.Command.ButtonCommand();
   this.LoadButton = new Crownwood.DotNetMagic.Controls.Command.ButtonCommand();
   this.DBSplitter = new System.Windows.Forms.Splitter();
   this.QueryGrid = new System.Windows.Forms.DataGrid();
   this.DBTree = new Crownwood.DotNetMagic.Controls.TreeControl();
   this.ResultSet = new System.Data.DataSet();
   this.DBImage = new System.Windows.Forms.ImageList(this.components);
   this.myBuilder = new System.Data.SqlClient.SqlCommandBuilder();
   this.IconsImage = new System.Windows.Forms.ImageList(this.components);
   this.OpenSQLDialog = new System.Windows.Forms.OpenFileDialog();
   this.DBQuery = new ActiproSoftware.SyntaxEditor.SyntaxEditor();
   ((System.ComponentModel.ISupportInitialize)(this.myDataSet)).BeginInit();
   ((System.ComponentModel.ISupportInitialize)(this.DBToolControl)).BeginInit();
   this.LeftPanel.SuspendLayout();
   this.DBTab.SuspendLayout();
   this.Attribute.SuspendLayout();
   ((System.ComponentModel.ISupportInitialize)(this.DBAttibute)).BeginInit();
   this.Broswer.SuspendLayout();
   ((System.ComponentModel.ISupportInitialize)(this.DBGrid)).BeginInit();
   this.BrowserPanel.SuspendLayout();
   this.panel1.SuspendLayout();
   ((System.ComponentModel.ISupportInitialize)(this.DBBrowserTool)).BeginInit();
   this.Query.SuspendLayout();
   ((System.ComponentModel.ISupportInitialize)(this.QueryTool)).BeginInit();
   ((System.ComponentModel.ISupportInitialize)(this.QueryGrid)).BeginInit();
   ((System.ComponentModel.ISupportInitialize)(this.ResultSet)).BeginInit();
   this.SuspendLayout();
   //
   // ConnectCMD
   //
   this.ConnectCMD.Description = "Menu";
   this.ConnectCMD.Text = "连接";
   this.ConnectCMD.Click += new System.EventHandler(this.ConnectCMD_Click);
   //
   // DBStatus
   //
   this.DBStatus.Location = new System.Drawing.Point(0, 418);
   this.DBStatus.Name = "DBStatus";
   this.DBStatus.Size = new System.Drawing.Size(704, 20);
   this.DBStatus.StatusPanels.AddRange(new Crownwood.DotNetMagic.Controls.StatusPanel[] {
                          this.TimePannel,
                          this.ItemPanel});
   this.DBStatus.Style = Crownwood.DotNetMagic.Common.VisualStyle.IDE2005;
   this.DBStatus.TabIndex = 2;
   //
   // TimePannel
   //
   this.TimePannel.AutoScrollMargin = new System.Drawing.Size(0, 0);
   this.TimePannel.AutoScrollMinSize = new System.Drawing.Size(0, 0);
   this.TimePannel.Location = new System.Drawing.Point(2, 2);
   this.TimePannel.Name = "TimePannel";
   this.TimePannel.RequestedWidth = 200;
   this.TimePannel.Size = new System.Drawing.Size(200, 14);
   this.TimePannel.TabIndex = 0;
   this.TimePannel.Text = "耗时:";
   //
   // ItemPanel
   //
   this.ItemPanel.AutoScrollMargin = new System.Drawing.Size(0, 0);
   this.ItemPanel.AutoScrollMinSize = new System.Drawing.Size(0, 0);
   this.ItemPanel.Location = new System.Drawing.Point(2, 2);
   this.ItemPanel.Name = "ItemPanel";
   this.ItemPanel.RequestedWidth = 200;
   this.ItemPanel.Size = new System.Drawing.Size(200, 14);
   this.ItemPanel.TabIndex = 0;
   this.ItemPanel.Text = "记录数:";
   //
   // myDataSet
   //
   this.myDataSet.DataSetName = "DBData";
   this.myDataSet.Locale = new System.Globalization.CultureInfo("zh-CN");
   //
   // ConnectButton
   //
   this.ConnectButton.Tag = null;
   this.ConnectButton.Text = "连接";
   this.ConnectButton.Click += new System.EventHandler(this.ConnectButton_Click);
   //
   // MainMenu
   //
   this.MainMenu.AllowLayered = true;
   this.MainMenu.AnimateStyle = Crownwood.DotNetMagic.Menus.Animation.System;
   this.MainMenu.AnimateTime = 100;
   this.MainMenu.BackColor = System.Drawing.SystemColors.Control;
   this.MainMenu.Cursor = System.Windows.Forms.Cursors.Arrow;
   this.MainMenu.Direction = Crownwood.DotNetMagic.Common.LayoutDirection.Horizontal;
   this.MainMenu.Dock = System.Windows.Forms.DockStyle.Top;
   this.MainMenu.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
   this.MainMenu.HighlightBackColor = System.Drawing.SystemColors.Highlight;
   this.MainMenu.HighlightTextColor = System.Drawing.SystemColors.MenuText;
   this.MainMenu.IgnoreF10 = false;
   this.MainMenu.Location = new System.Drawing.Point(0, 0);
   this.MainMenu.MenuCommands.AddRange(new Crownwood.DotNetMagic.Menus.MenuCommand[] {
                          this.FileCMD,
                          this.HelpCMD});
   this.MainMenu.Name = "MainMenu";
   this.MainMenu.PlainSelectedTextColor = System.Drawing.SystemColors.ActiveCaptionText;
   this.MainMenu.SelectedBackColor = System.Drawing.SystemColors.Control;
   this.MainMenu.SelectedTextColor = System.Drawing.SystemColors.MenuText;
   this.MainMenu.Size = new System.Drawing.Size(704, 25);
   this.MainMenu.Style = Crownwood.DotNetMagic.Common.VisualStyle.IDE2005;
   this.MainMenu.TabIndex = 0;
   this.MainMenu.TabStop = false;
   this.MainMenu.Text = "menuControl1";
   this.MainMenu.TextColor = System.Drawing.SystemColors.MenuText;
   //
   // FileCMD
   //
   this.FileCMD.Description = "Menu";
   this.FileCMD.MenuCommands.AddRange(new Crownwood.DotNetMagic.Menus.MenuCommand[] {
                         this.ConnectCMD,
                         this.DisConncetCMD});
   this.FileCMD.Text = "文件";
   //
   // DisConncetCMD
   //
   this.DisConncetCMD.Description = "Menu";
   this.DisConncetCMD.Text = "断开";
   this.DisConncetCMD.Click += new System.EventHandler(this.DisConncetCMD_Click);
   //
   // HelpCMD
   //
   this.HelpCMD.Description = "Menu";
   this.HelpCMD.Text = "帮助";
   this.HelpCMD.Click += new System.EventHandler(this.HelpCMD_Click);
   //
   // DBToolControl
   //
   this.DBToolControl.Commands.AddRange(new Crownwood.DotNetMagic.Controls.Command.CommandBase[] {
                             this.ConnectButton,
                             this.DisConnectButton});
   this.DBToolControl.Location = new System.Drawing.Point(0, 25);
   this.DBToolControl.Name = "DBToolControl";
   this.DBToolControl.Size = new System.Drawing.Size(704, 24);
   this.DBToolControl.Style = Crownwood.DotNetMagic.Common.VisualStyle.IDE2005;
   this.DBToolControl.TabIndex = 7;
   //
   // DisConnectButton
   //
   this.DisConnectButton.Tag = null;
   this.DisConnectButton.Text = "断开";
   this.DisConnectButton.Click += new System.EventHandler(this.DisConnectButton_Click);
   //
   // LeftPanel
   //
   this.LeftPanel.Controls.Add(this.MainSplitter);
   this.LeftPanel.Controls.Add(this.DBTab);
   this.LeftPanel.Controls.Add(this.DBTree);
   this.LeftPanel.Dock = System.Windows.Forms.DockStyle.Fill;
   this.LeftPanel.Location = new System.Drawing.Point(0, 49);
   this.LeftPanel.Name = "LeftPanel";
   this.LeftPanel.Size = new System.Drawing.Size(704, 369);
   this.LeftPanel.TabIndex = 16;
   //
   // MainSplitter
   //
   this.MainSplitter.Location = new System.Drawing.Point(181, 0);
   this.MainSplitter.Name = "MainSplitter";
   this.MainSplitter.Size = new System.Drawing.Size(3, 369);
   this.MainSplitter.TabIndex = 16;
   this.MainSplitter.TabStop = false;
   //
   // DBTab
   //
   this.DBTab.BackColor = System.Drawing.SystemColors.Control;
   this.DBTab.ButtonActiveColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)));
   this.DBTab.ButtonInactiveColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)));
   this.DBTab.Dock = System.Windows.Forms.DockStyle.Fill;
   this.DBTab.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
   this.DBTab.HotTextColor = System.Drawing.SystemColors.ActiveCaption;
   this.DBTab.ImageList = null;
   this.DBTab.Location = new System.Drawing.Point(181, 0);
   this.DBTab.Name = "DBTab";
   this.DBTab.OfficeDockSides = false;
   this.DBTab.SelectedIndex = 2;
   this.DBTab.ShowDropSelect = false;
   this.DBTab.Size = new System.Drawing.Size(523, 369);
   this.DBTab.Style = Crownwood.DotNetMagic.Common.VisualStyle.IDE2005;
   this.DBTab.TabIndex = 15;
   this.DBTab.TabPages.AddRange(new Crownwood.DotNetMagic.Controls.TabPage[] {
                        this.Attribute,
                        this.Broswer,
                        this.Query});
   this.DBTab.TextColor = System.Drawing.SystemColors.ControlText;
   this.DBTab.TextInactiveColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)));
   this.DBTab.TextTips = true;
   this.DBTab.Visible = false;
   //
   // Attribute
   //
   this.Attribute.Controls.Add(this.DBAttibute);
   this.Attribute.InactiveBackColor = System.Drawing.Color.Empty;
   this.Attribute.InactiveTextBackColor = System.Drawing.Color.Empty;
   this.Attribute.InactiveTextColor = System.Drawing.Color.Empty;
   this.Attribute.Location = new System.Drawing.Point(1, 1);
   this.Attribute.Name = "Attribute";
   this.Attribute.SelectBackColor = System.Drawing.Color.Empty;
   this.Attribute.Selected = false;
   this.Attribute.SelectTextBackColor = System.Drawing.Color.Empty;
   this.Attribute.SelectTextColor = System.Drawing.Color.Empty;
   this.Attribute.Size = new System.Drawing.Size(521, 342);
   this.Attribute.TabIndex = 6;
   this.Attribute.Title = "数据属性";
   this.Attribute.ToolTip = "数据属性";
   //
   // DBAttibute
   //
   this.DBAttibute.BackColor = System.Drawing.SystemColors.Control;
   this.DBAttibute.BackgroundColor = System.Drawing.SystemColors.InactiveBorder;
   this.DBAttibute.BorderStyle = System.Windows.Forms.BorderStyle.None;
   this.DBAttibute.CaptionBackColor = System.Drawing.SystemColors.AppWorkspace;
   this.DBAttibute.CaptionFont = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
   this.DBAttibute.DataMember = "";
   this.DBAttibute.Dock = System.Windows.Forms.DockStyle.Fill;
   this.DBAttibute.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
   this.DBAttibute.HeaderForeColor = System.Drawing.SystemColors.ControlText;
   this.DBAttibute.Location = new System.Drawing.Point(0, 0);
   this.DBAttibute.Name = "DBAttibute";
   this.DBAttibute.ReadOnly = true;
   this.DBAttibute.RowHeadersVisible = false;
   this.DBAttibute.Size = new System.Drawing.Size(521, 342);
   this.DBAttibute.TabIndex = 0;
   //
   // Broswer
   //
   this.Broswer.Controls.Add(this.DBGrid);
   this.Broswer.Controls.Add(this.BrowserPanel);
   this.Broswer.InactiveBackColor = System.Drawing.Color.Empty;
   this.Broswer.InactiveTextBackColor = System.Drawing.Color.Empty;
   this.Broswer.InactiveTextColor = System.Drawing.Color.Empty;
   this.Broswer.Location = new System.Drawing.Point(1, 1);
   this.Broswer.Name = "Broswer";
   this.Broswer.SelectBackColor = System.Drawing.Color.Empty;
   this.Broswer.Selected = false;
   this.Broswer.SelectTextBackColor = System.Drawing.Color.Empty;
   this.Broswer.SelectTextColor = System.Drawing.Color.Empty;
   this.Broswer.Size = new System.Drawing.Size(521, 342);
   this.Broswer.TabIndex = 4;
   this.Broswer.Title = "数据浏览器";
   this.Broswer.ToolTip = "Browser";
   //
   // DBGrid
   //
   this.DBGrid.DataMember = "";
   this.DBGrid.Dock = System.Windows.Forms.DockStyle.Fill;
   this.DBGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
   this.DBGrid.Location = new System.Drawing.Point(0, 24);
   this.DBGrid.Name = "DBGrid";
   this.DBGrid.Size = new System.Drawing.Size(521, 318);
   this.DBGrid.TabIndex = 8;
   //
   // BrowserPanel
   //
   this.BrowserPanel.Controls.Add(this.ModifyButton);
   this.BrowserPanel.Controls.Add(this.ItemCount);
   this.BrowserPanel.Controls.Add(this.panel1);
   this.BrowserPanel.Dock = System.Windows.Forms.DockStyle.Top;
   this.BrowserPanel.Location = new System.Drawing.Point(0, 0);
   this.BrowserPanel.Name = "BrowserPanel";
   this.BrowserPanel.Size = new System.Drawing.Size(521, 24);
   this.BrowserPanel.TabIndex = 7;
   //
   // ModifyButton
   //
   this.ModifyButton.Location = new System.Drawing.Point(312, 0);
   this.ModifyButton.Name = "ModifyButton";
   this.ModifyButton.Size = new System.Drawing.Size(40, 23);
   this.ModifyButton.Style = Crownwood.DotNetMagic.Common.VisualStyle.IDE2005;
   this.ModifyButton.TabIndex = 2;
   this.ModifyButton.Text = "修改";
   this.ModifyButton.Click += new System.EventHandler(this.ModifyButton_Click);
   //
   // ItemCount
   //
   this.ItemCount.Location = new System.Drawing.Point(232, 0);
   this.ItemCount.Name = "ItemCount";
   this.ItemCount.Size = new System.Drawing.Size(64, 21);
   this.ItemCount.TabIndex = 1;
   this.ItemCount.Text = "1000";
   this.ItemCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
   //
   // panel1
   //
   this.panel1.Controls.Add(this.DBBrowserTool);
   this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
   this.panel1.Location = new System.Drawing.Point(0, 0);
   this.panel1.Name = "panel1";
   this.panel1.Size = new System.Drawing.Size(232, 24);
   this.panel1.TabIndex = 0;
   //
   // DBBrowserTool
   //
   this.DBBrowserTool.Commands.AddRange(new Crownwood.DotNetMagic.Controls.Command.CommandBase[] {
                             this.UpdataCMDButton,
                             this.UpdateCancelButton,
                             this.RefreshButton});
   this.DBBrowserTool.Location = new System.Drawing.Point(0, 0);
   this.DBBrowserTool.Name = "DBBrowserTool";
   this.DBBrowserTool.Size = new System.Drawing.Size(232, 23);
   this.DBBrowserTool.Style = Crownwood.DotNetMagic.Common.VisualStyle.IDE2005;
   this.DBBrowserTool.TabIndex = 1;
   //
   // UpdataCMDButton
   //
   this.UpdataCMDButton.Tag = null;
   this.UpdataCMDButton.Text = "更新";
   this.UpdataCMDButton.Click += new System.EventHandler(this.UpdataCMDButton_Click);
   //
   // UpdateCancelButton
   //
   this.UpdateCancelButton.Tag = null;
   this.UpdateCancelButton.Text = "取消修改";
   this.UpdateCancelButton.Click += new System.EventHandler(this.UpdateCancelButton_Click);
   //
   // RefreshButton
   //
   this.RefreshButton.Tag = null;
   this.RefreshButton.Text = "刷新";
   this.RefreshButton.Click += new System.EventHandler(this.RefreshButton_Click);
   //
   // Query
   //
   this.Query.Controls.Add(this.DBQuery);
   this.Query.Controls.Add(this.QueryTool);
   this.Query.Controls.Add(this.DBSplitter);
   this.Query.Controls.Add(this.QueryGrid);
   this.Query.InactiveBackColor = System.Drawing.Color.Empty;
   this.Query.InactiveTextBackColor = System.Drawing.Color.Empty;
   this.Query.InactiveTextColor = System.Drawing.Color.Empty;
   this.Query.Location = new System.Drawing.Point(1, 1);
   this.Query.Name = "Query";
   this.Query.SelectBackColor = System.Drawing.Color.Empty;
   this.Query.SelectTextBackColor = System.Drawing.Color.Empty;
   this.Query.SelectTextColor = System.Drawing.Color.Empty;
   this.Query.Size = new System.Drawing.Size(521, 342);
   this.Query.TabIndex = 5;
   this.Query.Title = "数据查询";
   this.Query.ToolTip = "数据查询";
   //
   // QueryTool
   //
   this.QueryTool.Commands.AddRange(new Crownwood.DotNetMagic.Controls.Command.CommandBase[] {
                            this.UpdataCMDButton,
                            this.ExecuteButton,
                            this.UpdateCannel,
                            this.QueryRefresh,
                            this.LoadButton});
   this.QueryTool.Location = new System.Drawing.Point(0, 0);
   this.QueryTool.Name = "QueryTool";
   this.QueryTool.Size = new System.Drawing.Size(521, 23);
   this.QueryTool.Style = Crownwood.DotNetMagic.Common.VisualStyle.IDE2005;
   this.QueryTool.TabIndex = 3;
   //
   // ExecuteButton
   //
   this.ExecuteButton.Tag = null;
   this.ExecuteButton.Text = "执行";
   this.ExecuteButton.Click += new System.EventHandler(this.ExecuteButton_Click);
   //
   // UpdateCannel
   //
   this.UpdateCannel.Tag = null;
   this.UpdateCannel.Text = "取消修改";
   this.UpdateCannel.Click += new System.EventHandler(this.UpdateCancelButton_Click);
   //
   // QueryRefresh
   //
   this.QueryRefresh.Tag = null;
   this.QueryRefresh.Text = "刷新";
   this.QueryRefresh.Click += new System.EventHandler(this.RefreshButton_Click);
   //
   // LoadButton
   //
   this.LoadButton.Tag = null;
   this.LoadButton.Text = "载入Sql";
   this.LoadButton.Click += new System.EventHandler(this.LoadButton_Click);
   //
   // DBSplitter
   //
   this.DBSplitter.Dock = System.Windows.Forms.DockStyle.Bottom;
   this.DBSplitter.Location = new System.Drawing.Point(0, 149);
   this.DBSplitter.Name = "DBSplitter";
   this.DBSplitter.Size = new System.Drawing.Size(521, 1);
   this.DBSplitter.TabIndex = 2;
   this.DBSplitter.TabStop = false;
   //
   // QueryGrid
   //
   this.QueryGrid.DataMember = "";
   this.QueryGrid.Dock = System.Windows.Forms.DockStyle.Bottom;
   this.QueryGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
   this.QueryGrid.Location = new System.Drawing.Point(0, 150);
   this.QueryGrid.Name = "QueryGrid";
   this.QueryGrid.Size = new System.Drawing.Size(521, 192);
   this.QueryGrid.TabIndex = 1;
   this.QueryGrid.Visible = false;
   //
   // DBTree
   //
   this.DBTree.BorderStyle = Crownwood.DotNetMagic.Controls.TreeBorderStyle.None;
   this.DBTree.BoxDrawStyle = Crownwood.DotNetMagic.Controls.DrawStyle.Plain;
   this.DBTree.Dock = System.Windows.Forms.DockStyle.Left;
   this.DBTree.FocusNode = null;
   this.DBTree.GroupAutoAllocate = true;
   this.DBTree.GroupAutoCollapse = true;
   this.DBTree.GroupBackColor = System.Drawing.SystemColors.ControlDarkDark;
   this.DBTree.GroupClickExpand = Crownwood.DotNetMagic.Controls.ClickExpandAction.Expand;
   this.DBTree.GroupFont = new System.Drawing.Font("Arial", 11F, System.Drawing.FontStyle.Bold);
   this.DBTree.GroupForeColor = System.Drawing.SystemColors.ActiveCaptionText;
   this.DBTree.GroupHotFontStyle = System.Drawing.FontStyle.Bold;
   this.DBTree.GroupImageBox = true;
   this.DBTree.GroupImageBoxBackColor = System.Drawing.SystemColors.InactiveCaption;
   this.DBTree.GroupImageBoxColumnColor = System.Drawing.SystemColors.ControlDark;
   this.DBTree.GroupImageBoxGradientBack = true;
   this.DBTree.GroupImageBoxLineColor = System.Drawing.SystemColors.ControlText;
   this.DBTree.GroupImageBoxSelectedBackColor = System.Drawing.SystemColors.InactiveCaption;
   this.DBTree.GroupNodesSelectable = false;
   this.DBTree.GroupSelectedBackColor = System.Drawing.SystemColors.Info;
   this.DBTree.GroupSelectedFontStyle = System.Drawing.FontStyle.Bold;
   this.DBTree.GroupSelectedForeColor = System.Drawing.SystemColors.InfoText;
   this.DBTree.GroupSelectedNoFocusBackColor = System.Drawing.SystemColors.Info;
   this.DBTree.HotBackColor = System.Drawing.Color.Empty;
   this.DBTree.HotForeColor = System.Drawing.Color.Empty;
   this.DBTree.Location = new System.Drawing.Point(0, 0);
   this.DBTree.MinimumNodeHeight = 14;
   this.DBTree.Name = "DBTree";
   this.DBTree.SelectedBackColor = System.Drawing.SystemColors.InactiveCaptionText;
   this.DBTree.SelectedNode = null;
   this.DBTree.SelectedNoFocusBackColor = System.Drawing.SystemColors.Control;
   this.DBTree.Size = new System.Drawing.Size(181, 369);
   this.DBTree.TabIndex = 0;
   this.DBTree.VerticalGranularity = Crownwood.DotNetMagic.Controls.VerticalGranularity.Pixel;
   this.DBTree.ViewControllers = Crownwood.DotNetMagic.Controls.ViewControllers.Group;
   this.DBTree.AfterSelect += new Crownwood.DotNetMagic.Controls.NodeEventHandler(this.DBTree_AfterSelect);
   this.DBTree.BeforeExpand += new Crownwood.DotNetMagic.Controls.CancelNodeEventHandler(this.DBTree_BeforeExpand);
   //
   // ResultSet
   //
   this.ResultSet.DataSetName = "DBData2";
   this.ResultSet.Locale = new System.Globalization.CultureInfo("zh-CN");
   //
   // DBImage
   //
   this.DBImage.ImageSize = new System.Drawing.Size(16, 16);
   this.DBImage.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("DBImage.ImageStream")));
   this.DBImage.TransparentColor = System.Drawing.Color.Magenta;
   //
   // IconsImage
   //
   this.IconsImage.ImageSize = new System.Drawing.Size(18, 20);
   this.IconsImage.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("IconsImage.ImageStream")));
   this.IconsImage.TransparentColor = System.Drawing.Color.Transparent;
   //
   // OpenSQLDialog
   //
   this.OpenSQLDialog.Filter = "Sql脚本(*.sql)|*.sql";
   this.OpenSQLDialog.Title = "打开Sql文件";
   //
   // DBQuery
   //
   this.DBQuery.AllowDrop = true;
   this.DBQuery.Dock = System.Windows.Forms.DockStyle.Fill;
   this.DBQuery.Document = document1;
   this.DBQuery.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
   this.DBQuery.LineNumberMarginVisible = true;
   this.DBQuery.LineNumberMarginWidth = 25;
   this.DBQuery.Location = new System.Drawing.Point(0, 23);
   this.DBQuery.Name = "DBQuery";
   this.DBQuery.Size = new System.Drawing.Size(521, 126);
   this.DBQuery.TabIndex = 6;
   //
   // DBForm
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(704, 438);
   this.Controls.Add(this.LeftPanel);
   this.Controls.Add(this.DBToolControl);
   this.Controls.Add(this.MainMenu);
   this.Controls.Add(this.DBStatus);
   this.Name = "DBForm";
   this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
   this.Text = "SqlServerClient";
   this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
   this.Closing += new System.ComponentModel.CancelEventHandler(this.DBForm_Closing);
   this.Load += new System.EventHandler(this.DBForm_Load);
   ((System.ComponentModel.ISupportInitialize)(this.myDataSet)).EndInit();
   ((System.ComponentModel.ISupportInitialize)(this.DBToolControl)).EndInit();
   this.LeftPanel.ResumeLayout(false);
   this.DBTab.ResumeLayout(false);
   this.Attribute.ResumeLayout(false);
   ((System.ComponentModel.ISupportInitialize)(this.DBAttibute)).EndInit();
   this.Broswer.ResumeLayout(false);
   ((System.ComponentModel.ISupportInitialize)(this.DBGrid)).EndInit();
   this.BrowserPanel.ResumeLayout(false);
   this.panel1.ResumeLayout(false);
   ((System.ComponentModel.ISupportInitialize)(this.DBBrowserTool)).EndInit();
   this.Query.ResumeLayout(false);
   ((System.ComponentModel.ISupportInitialize)(this.QueryTool)).EndInit();
   ((System.ComponentModel.ISupportInitialize)(this.QueryGrid)).EndInit();
   ((System.ComponentModel.ISupportInitialize)(this.ResultSet)).EndInit();
   this.ResumeLayout(false);

  }
  #endregion

  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main()
  {
   Application.Run(new DBForm());
  }


  private void ExecuteButton_Click(object sender, System.EventArgs e)
  {
   DateTime dt=DateTime.Now;
   Execute();
   TimeSpan ts=DateTime.Now.Subtract(dt);
   TimePannel.Text="耗时:"+ts.TotalSeconds+"秒";
   DBStatus.Refresh();
  }
  private void Execute()
  {
   try
   {
    QueryGrid.SetDataBinding(null,"");
    CMDStr=DBQuery.Text;
    SqlCommand SelectCMD=new SqlCommand(CMDStr,myConnection);
    SelectCMD.CommandTimeout=CommandTime;
    SQLDataAdapter=new SqlDataAdapter(SelectCMD);
    myBuilder= new SqlCommandBuilder(SQLDataAdapter);
                if (ResultSet.Tables[CurrentQuery] != null)
                    ResultSet.Tables[CurrentQuery].Clear();
    SQLDataAdapter.Fill(ResultSet,"Result");

    QueryGrid.SetDataBinding(ResultSet,"Result");
    QueryGrid.Visible=true;
    ItemPanel.Text="记录数:"+ResultSet.Tables["Result"].Rows.Count;
    CurrentQuery="Result";
   }
   catch(Exception ex)
   {
    ShowError("Execute Error",ex.ToString());
   }
  }
  private  void ShowError(String caption,String ex)
  {
   Message m=new Message();
   m.CaptionText=caption;
   m.Error=ex;
   m.ShowDialog();
  }
  private void ConnectCMD_Click(object sender, System.EventArgs e)
  {
    ConnectFun();
  }
  private void ConnectFun()
  {
   try
   {
    ConnectForm cf=new ConnectForm();
    cf.Connected=true;
    cf.ShowDialog();
    if(cf.Connected==false)
     return;
    Server=cf.Server;
    Port=cf.Port;
    UserName=cf.UserName;
    Password=cf.Password;
    DataBase=cf.DataBase;
    ConnectedTime=cf.TimeOut;
    CommandTime=cf.CommandTimeOut;

    if(DataBase!="")
    {

     String myString="server="+Server+";database="+DataBase+";uid="+UserName+";pwd="+Password+";Connect Timeout="+ConnectedTime+";";
     myConnection=new SqlConnection(myString);
     myConnection.Open();

     DBTab.TabPages[1].Selected=true;
     DBTab.Visible=true;

     Node ServerNode=new Node(Server);
     ServerNode.Image=IconsImage.Images[0];
     ServerNode.Selectable=false;
     DBTree.Nodes.Add(ServerNode);

     DBTree.Nodes.Add(new Node(DataBase));
     DBTree.Nodes[1].Nodes.Add(new Node("TABLE"));
     DBTree.Nodes[1].Nodes.Add(new Node("SYSTEM TABLE"));
     DBTree.Nodes[1].Nodes.Add(new Node("VIEW"));
     DBTree.Nodes[1].Image=IconsImage.Images[1];
    }
    else
    {
     

     String myString="server="+Server+";database="+DataBase+";uid="+UserName+";pwd="+Password+";Connect Timeout="+ConnectedTime+";";
     myConnection=new SqlConnection(myString);
     myConnection.Open();

     String CMD="exec sp_databases";
     SQLDataAdapter=new SqlDataAdapter(CMD,myConnection);
     SQLDataAdapter.Fill(myDataSet,"AllDB");
     
     DBTab.Visible=true;

     Node ServerNode=new Node(Server);
     ServerNode.Image=IconsImage.Images[0];
     ServerNode.Selectable=false;
     DBTree.Nodes.Add(ServerNode);

     int len=myDataSet.Tables["AllDB"].Rows.Count;
     for(int i=0;i<len;i++)
     {
      DBTree.Nodes.Add(new Node(myDataSet.Tables[0].Rows[i][0].ToString()));
      DBTree.Nodes[i+1].Nodes.Add(new Node("TABLE"));
      DBTree.Nodes[i+1].Nodes.Add(new Node("SYSTEM TABLE"));
      DBTree.Nodes[i+1].Nodes.Add(new Node("VIEW"));
      DBTree.Nodes[i+1].Image=IconsImage.Images[1];
     }
    }
    ConnectCMD.Enabled=false;
    ConnectButton.Enabled=false;
    DisConncetCMD.Enabled=true;
    DisConnectButton.Enabled=true;
    LastBrowserSql=LastBrowserTable=null;
   }
   catch(Exception ex)
   {
    ShowError("Connect Error",ex.ToString());
   }
  }
  private void DisConnectFun()
  {
   try
   {
    myDataSet.Clear();
    DBTree.Nodes.Clear();
    QueryGrid.SetDataBinding(null,"");
    DBGrid.SetDataBinding(null,"");
    DBTab.Visible=false;
    ConnectCMD.Enabled=true;
    ConnectButton.Enabled=true;
    DisConncetCMD.Enabled=false;
    DisConnectButton.Enabled=false;
       myConnection.Close();
   }
   catch(Exception ex)
   {
   }
  }
  private void DisConncetCMD_Click(object sender, System.EventArgs e)
  {
   DisConnectFun();
  }

  private void DBTree_AfterSelect(Crownwood.DotNetMagic.Controls.TreeControl tc, Crownwood.DotNetMagic.Controls.NodeEventArgs e)
  {
   try
   {
    if(e.Node.Parent==null||e.Node.Parent.Parent==null)
     return;
    CountofItem=1000;
    Cursor.Current=Cursors.WaitCursor;
    CurrentBrowser="Content"+e.Node.Text;
    DBGrid.SetDataBinding(null,null);
    if(myDataSet.Tables["Content"+e.Node.Text]!=null)
     myDataSet.Tables["Content"+e.Node.Text].Clear();

    String CMD="use "+e.Node.Parent.Parent.Text+" exec sp_columns "+e.Node.Text;
    SQLDataAdapter=new SqlDataAdapter(CMD,myConnection);
    SQLDataAdapter.Fill(myDataSet,"Attribute"+e.Node.Text);

    DBAttibute.SetDataBinding(myDataSet,"Attribute"+e.Node.Text);


    LastBrowserSql="select top "+CountofItem+" * from "+e.Node.Parent.Parent.Text+".dbo."+e.Node.Text;
    LastBrowserTable=e.Node.Parent.Parent.Text+".dbo."+e.Node.Text;
    SQLDataAdapter=new SqlDataAdapter(LastBrowserSql,myConnection);
    myBuilder= new SqlCommandBuilder(SQLDataAdapter);
    SQLDataAdapter.Fill(myDataSet,"Content"+e.Node.Text);
    DBGrid.SetDataBinding(myDataSet,"Content"+e.Node.Text);
    DBTab.TabPages[1].Selected=true;
    Cursor.Current=Cursors.Default;
    ItemPanel.Text="记录数:"+myDataSet.Tables["Content"+e.Node.Text].Rows.Count;
   }
   catch(Exception ex)
   {
    ShowError("Browser Error",ex.ToString());
   }
  }

  private void DBTree_BeforeExpand(Crownwood.DotNetMagic.Controls.TreeControl tc, Crownwood.DotNetMagic.Controls.CancelNodeEventArgs e)
  {
   try
   {
    if((e.Node.Parent!=null&&e.Node.Parent.Parent!=null)||e.Node.Text==Server)
     return;
    else if(e.Node.Parent!=null)
    {
     e.Node.Nodes.Clear();
     String CMD="use "+e.Node.Parent.Text+" exec sp_tables" ;
     SQLDataAdapter=new SqlDataAdapter(CMD,myConnection);
     if(myDataSet.Tables["Table"+e.Node.Parent.Text]!=null)
      myDataSet.Tables["Table"+e.Node.Parent.Text].Clear();
     SQLDataAdapter.Fill(myDataSet,"Table"+e.Node.Parent.Text);
   
     int len=myDataSet.Tables["Table"+e.Node.Parent.Text].Rows.Count;
     for(int i=0;i<len;i++)
     {
      if(myDataSet.Tables["Table"+e.Node.Parent.Text].Rows[i][3].ToString()==e.Node.Text)
      {
       Node tmpNode=new Node(myDataSet.Tables["Table"+e.Node.Parent.Text].Rows[i][2].ToString());
       tmpNode.Image=DBImage.Images[0];
       e.Node.Nodes.Add(tmpNode);
      }
      
     }
    }
    else
    {
     for(int i=0;i<e.Node.Nodes.Count;i++)
     {
      e.Node.Nodes[i].Image=DBImage.Images[1];
      e.Node.Nodes[i].Nodes.Add(new Node(""));
     }
    }
   }
   catch(Exception ex)
   {
    ShowError("Error",ex.ToString());
   }
  }

  private void ConnectButton_Click(object sender, System.EventArgs e)
  {
   ConnectFun();
  }

  private void DisConnectButton_Click(object sender, System.EventArgs e)
  {
   DisConnectFun();
  }

  private void UpdataCMDButton_Click(object sender, System.EventArgs e)
  {
   try
   {
    if(DBTab.TabPages[2].Selected)
     SQLDataAdapter.Update(ResultSet,CurrentQuery);
    else
     SQLDataAdapter.Update(myDataSet,CurrentBrowser);
   }
   catch(Exception ex)
   {
    ShowError("Update Error",ex.ToString());
   }
  }

  private void UpdateCancelButton_Click(object sender, System.EventArgs e)
  {
   try
   {
    if(DBTab.TabPages[1].Selected)
    {
     if(myDataSet.Tables[CurrentBrowser]!=null)
      myDataSet.Tables[CurrentBrowser].Clear();
     SQLDataAdapter=new SqlDataAdapter(LastBrowserSql,myConnection);
     myBuilder= new SqlCommandBuilder(SQLDataAdapter);
     SQLDataAdapter.Fill(myDataSet,CurrentBrowser);
     DBGrid.SetDataBinding(myDataSet,CurrentBrowser);
    }
    else
    {
     if(ResultSet.Tables[CurrentQuery]!=null)
                        ResultSet.Tables[CurrentQuery].Clear() ;
     SQLDataAdapter=new SqlDataAdapter(CMDStr,myConnection);
     myBuilder= new SqlCommandBuilder(SQLDataAdapter);
     SQLDataAdapter.Fill(ResultSet,"Result");

     QueryGrid.SetDataBinding(ResultSet,"Result");
    }
   }
   catch(Exception ex)
   {
    ShowError("UpdateCancel Error",ex.ToString());
   }
  }

  private void RefreshButton_Click(object sender, System.EventArgs e)
  {
   if(DBTab.TabPages[2].Selected)
    DBGrid.Refresh();
   else
    QueryGrid.Refresh();
  }

  private void HelpCMD_Click(object sender, System.EventArgs e)
  {
   Help h=new Help();
   h.ShowDialog();
  }

  private void ModifyButton_Click(object sender, System.EventArgs e)
  {
   if(LastBrowserSql==null||LastBrowserTable==null)
    return;
   CountofItem=int.Parse(ItemCount.Text);
   LastBrowserSql="select top "+CountofItem+" * from "+LastBrowserTable;
   SQLDataAdapter=new SqlDataAdapter(LastBrowserSql,myConnection);
   myBuilder= new SqlCommandBuilder(SQLDataAdapter);
   if(myDataSet.Tables[CurrentBrowser]!=null)
    myDataSet.Tables[CurrentBrowser].Clear();
   SQLDataAdapter.Fill(myDataSet,CurrentBrowser);
   DBGrid.SetDataBinding(myDataSet,CurrentBrowser);
  }

  private void DBForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  {
   DisConnectFun();
  }

  private void DBForm_Load(object sender, System.EventArgs e)
  {
   //DBQuery.Text="select/n/tc_name,/n/tc_custkey,/n/to_orderkey,/n/to_orderdate,/n/to_totalprice,/n/tsum(l_quantity)/nfrom/n/tcustomer,/n/torders,/n/tlineitem/nwhere/n/to_orderkey in (/n/t/tselect/n/t/t/tl_orderkey/n/t/tfrom/n/t/t/tlineitem/n/t/tgroup by/n/t/t/tl_orderkey /n/t/thaving/n/t/t/tsum(l_quantity) > [QUANTITY]/n/t/t)/n/tand c_custkey = o_custkey/n/tand o_orderkey = l_orderkey/ngroup by/n/tc_name,/n/tc_custkey,/n/to_orderkey,/n/to_orderdate,/n/to_totalprice/norder by/n/to_totalprice desc,/n/to_orderdate";
   DBQuery.Document.LoadLanguageFromXml("SQL.xml",0);
  }

  private void LoadButton_Click(object sender, System.EventArgs e)
  {
   if(OpenSQLDialog.ShowDialog()==DialogResult.OK)
   {
    StreamReader sr=new StreamReader(OpenSQLDialog.FileName);
    DBQuery.Text=sr.ReadToEnd();
    sr.Close();
   }
  }
 }
}

Message.cs

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

namespace dbTool
{
 /// <summary>
 /// Message 的摘要说明。
 /// </summary>
 public class Message : System.Windows.Forms.Form
 {
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;
  private System.Windows.Forms.Panel panel1;
  private System.Windows.Forms.RichTextBox ErrorText;
  private Crownwood.DotNetMagic.Controls.ButtonWithStyle ConButton;
  public String Error;
  public String CaptionText;
  public Message()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if(components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   this.panel1 = new System.Windows.Forms.Panel();
   this.ErrorText = new System.Windows.Forms.RichTextBox();
   this.ConButton = new Crownwood.DotNetMagic.Controls.ButtonWithStyle();
   this.panel1.SuspendLayout();
   this.SuspendLayout();
   //
   // panel1
   //
   this.panel1.Controls.Add(this.ConButton);
   this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
   this.panel1.Location = new System.Drawing.Point(0, 226);
   this.panel1.Name = "panel1";
   this.panel1.Size = new System.Drawing.Size(292, 40);
   this.panel1.TabIndex = 1;
   //
   // ErrorText
   //
   this.ErrorText.Dock = System.Windows.Forms.DockStyle.Fill;
   this.ErrorText.Location = new System.Drawing.Point(0, 0);
   this.ErrorText.Name = "ErrorText";
   this.ErrorText.ReadOnly = true;
   this.ErrorText.Size = new System.Drawing.Size(292, 226);
   this.ErrorText.TabIndex = 2;
   this.ErrorText.Text = "";
   //
   // ConButton
   //
   this.ConButton.Location = new System.Drawing.Point(104, 8);
   this.ConButton.Name = "ConButton";
   this.ConButton.Size = new System.Drawing.Size(75, 23);
   this.ConButton.Style = Crownwood.DotNetMagic.Common.VisualStyle.IDE2005;
   this.ConButton.TabIndex = 0;
   this.ConButton.Text = "确定";
   this.ConButton.Click += new System.EventHandler(this.ConButton_Click);
   //
   // Message
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(292, 266);
   this.Controls.Add(this.ErrorText);
   this.Controls.Add(this.panel1);
   this.Name = "Message";
   this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
   this.Text = "Message";
   this.Load += new System.EventHandler(this.Message_Load);
   this.panel1.ResumeLayout(false);
   this.ResumeLayout(false);

  }
  #endregion

  private void Message_Load(object sender, System.EventArgs e)
  {
   ErrorText.Text=Error;
   this.Text=CaptionText;
  }

  private void ConButton_Click(object sender, System.EventArgs e)
  {
   this.Close();
  }
 }
}

Help.cs

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

namespace dbTool
{
 /// <summary>
 /// Help 的摘要说明。
 /// </summary>
 public class Help : System.Windows.Forms.Form
 {
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.LinkLabel linkLabel1;
        private Crownwood.DotNetMagic.Controls.ButtonWithStyle buttonWithStyle1;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;

  public Help()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if(components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
            this.label1 = new System.Windows.Forms.Label();
            this.linkLabel1 = new System.Windows.Forms.LinkLabel();
            this.buttonWithStyle1 = new Crownwood.DotNetMagic.Controls.ButtonWithStyle();
            this.SuspendLayout();
            //
            // label1
            //
            this.label1.Location = new System.Drawing.Point(35, 48);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(64, 23);
            this.label1.TabIndex = 0;
            this.label1.Text = "comebaby";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            //
            // linkLabel1
            //
            this.linkLabel1.Location = new System.Drawing.Point(131, 48);
            this.linkLabel1.Name = "linkLabel1";
            this.linkLabel1.Size = new System.Drawing.Size(128, 23);
            this.linkLabel1.TabIndex = 6;
            this.linkLabel1.TabStop = true;
            this.linkLabel1.Text = "[email protected]";
            this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
            //
            // buttonWithStyle1
            //
            this.buttonWithStyle1.Location = new System.Drawing.Point(75, 106);
            this.buttonWithStyle1.Name = "buttonWithStyle1";
            this.buttonWithStyle1.Size = new System.Drawing.Size(128, 23);
            this.buttonWithStyle1.Style = Crownwood.DotNetMagic.Common.VisualStyle.IDE2005;
            this.buttonWithStyle1.TabIndex = 9;
            this.buttonWithStyle1.Text = "确定";
            this.buttonWithStyle1.Click += new System.EventHandler(this.buttonWithStyle1_Click);
            //
            // Help
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClientSize = new System.Drawing.Size(292, 230);
            this.Controls.Add(this.buttonWithStyle1);
            this.Controls.Add(this.linkLabel1);
            this.Controls.Add(this.label1);
            this.Name = "Help";
            this.Text = "Help";
            this.ResumeLayout(false);

  }
  #endregion


  private void buttonWithStyle1_Click(object sender, System.EventArgs e)
  {
   this.Close();
  }

  private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
  {
   System.Diagnostics.Process.Start("mailto:[email protected]");
  }


 }
}

代码写得比较乱。。。见笑了。。

另有Mysql版的,就不贴出来了。差不多的,就是要用到一个MySQL_Data_Provider_for_DotNet的库

;