Пример #1
0
        public FrmDataBaseQuery(ServerTag serverTag, string strDbName, string strDefaultSql, bool blnAutoRun)
        {
            InitializeComponent();

            txtSql.ShowEOLMarkers                = false;
            txtSql.ShowHRuler                    = false;
            txtSql.ShowInvalidLines              = false;
            txtSql.ShowMatchingBracket           = true;
            txtSql.ShowSpaces                    = false;
            txtSql.ShowTabs                      = false;
            txtSql.ShowVRuler                    = false;
            txtSql.AllowCaretBeyondEOL           = false;
            txtSql.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("SQL");
            txtSql.Encoding                      = Encoding.GetEncoding("GB2312");

            bckWorker.WorkerReportsProgress = true;
            this.m_dtDbName  = serverTag.ServerDBNames;
            this.m_strServer = serverTag.Server;
            this.m_strDbName = strDbName;
            this.m_serverTag = serverTag;
            this.Text        = m_strDbName + @"查询";
            ComboboxHelper.BindCombobox(cboDbName, serverTag.ServerDBNames, "name", "name", false);
            this.cboDbName.Text             = m_strDbName;
            cboDbName.SelectedIndexChanged += cboDbName_SelectedIndexChanged;
            if (strDefaultSql != string.Empty)
            {
                txtSql.Text = strDefaultSql;
                if (blnAutoRun)
                {
                    cmdRun_Click(null, null);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="strServer">服务器名称</param>
 /// <param name="strDbName">数据库名称</param>
 /// <param name="strTableName">数据库表名</param>
 /// <param name="dbType">类型</param>
 public FrmTableView(ServerTag serverTag, string strDbName, string strTableName)
 {
     InitializeComponent();
     m_strTableName    = strTableName;
     m_strServer       = serverTag.Server;
     m_strDbName       = strDbName;
     m_dbType          = serverTag.DBType;
     grdTable.EditMode = DataGridViewEditMode.EditOnEnter;
     this.Text         = "打开表" + "_" + m_strServer + "_" + m_strDbName + "_" + m_strTableName;
     m_databaseSchema  = GlobalHelp.GetDatabaseSchema(serverTag.DBType, serverTag.Server, strDbName);
     m_dbHelper        = DataBaseManager.GetDbHelper(m_dbType, m_databaseSchema.ConnectionString);
     m_lstCopyRow      = new List <DataRow>();
     BindGrid(m_strTableName);
 }
Пример #3
0
 /// <summary>
 /// 构造函数 构造函数
 /// </summary>
 /// <param name="strServer">服务器名称</param>
 /// <param name="strDbName">数据库名称</param>
 /// <param name="strTableName">数据库表名</param>
 /// <param name="dbType">类型</param>
 /// <param name="blnNew">是否新增表,true 新增表,false,设计表</param>
 public FrmTableNew(ServerTag serverTag, string strDbName, string strTableName, SqlType dbType, bool blnNew)
 {
     InitializeComponent();
     m_dal                        = new Bse_DataDictionaryDAL();
     m_strTableName               = strTableName;
     m_strServer                  = serverTag.Server;
     m_strDbName                  = strDbName;
     m_dbType                     = dbType;
     grdTable.EditMode            = DataGridViewEditMode.EditOnEnter;
     grdTable.AutoGenerateColumns = false;
     m_databaseSchema             = GlobalHelp.GetDatabaseSchema(serverTag.DBType, serverTag.Server, strDbName);
     m_dbHelper                   = DataBaseManager.GetDbHelper(m_dbType, m_databaseSchema.ConnectionString);
     m_sqlTasks                   = new SqlTasks(m_dbType);
     m_blnNew                     = blnNew;
 }
Пример #4
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            if (cboServer.Text == string.Empty)
            {
                MessageBox.Show("请选择要执行的服务器");
                return;
            }
            if (txtSql.Text.Trim() == string.Empty)
            {
                MessageBox.Show("请选择要执行的语句");
                return;
            }
            TreeNode treeNode = tvwAnalyze.SelectedNode;
            DataRow  dr       = treeNode.Tag as DataRow;

            if (dr != null)
            {
                string    strDbType     = dr["DbType"].ToString();
                string    strExcuteType = dr["ExcuteType"].ToString();
                TreeNode  treeNodeFind  = FindTreeNodeByName(cboServer.Text.Trim());
                ServerTag serverTag     = treeNodeFind.Tag as ServerTag;
                if (serverTag != null)
                {
                    SqlType dbType = GetSqlType(strDbType);
                    if (serverTag.DBType != dbType)
                    {
                        MessageBox.Show("选中的语句不支持在" + serverTag.DBType + "服务器下执行");
                        return;
                    }
                    IDBHelper dbHelper = DataBaseManager.GetDbHelper(dbType, serverTag.MasterConn);
                    switch (strExcuteType)
                    {
                    case "SQL语句":
                        dbHelper.CreateCommand(txtSql.Text.Trim());
                        break;

                    case "存储过程":
                        dbHelper.CreateStoredCommand(txtSql.Text.Trim());
                        break;
                    }
                    DataSet ds = dbHelper.ExecuteQueryDataSet();
                    if (ds.Tables.Count > 0)
                    {
                        grdResult.DataSource = ds.Tables[0];
                    }
                }
            }
        }