Example #1
0
        /// <summary>
        /// 执行sql语句
        /// </summary>
        private void toolStripButton_run_Click(object sender, EventArgs e)
        {
            string sql = tbx_sql.Text;

            if (string.IsNullOrWhiteSpace(sql))
            {
                MessageBox.Show("查询语句不能为空");
            }
            else if (toolStripComboBox_dbs.SelectedIndex == -1)
            {
                MessageBox.Show("请选择数据库");
            }
            else
            {
                //执行前先清空之前结果
                dataGridView_result.DataSource = null;

                string dbName = (string)toolStripComboBox_dbs.Text;
                //dbManagerService.ExecuteReader(_shellData.ShellExtraSetting, dbName, sql);


                if (sql.ToLower().StartsWith("select"))
                {
                    dbManagerService.ExecuteReader(GetConnStr(), dbName, sql);
                }
                else
                {
                    dbManagerService.ExecuteNonQuery(GetConnStr(), dbName, sql);
                }
            }
        }
Example #2
0
        /// <summary>
        /// 执行sql语句
        /// </summary>
        private void toolStripButton_run_Click(object sender, EventArgs e)
        {
            string sql = tbx_sql.Text;

            if (string.IsNullOrWhiteSpace(sql))
            {
                MessageBox.Show("the query sql cannot be empty");
            }
            else if (toolStripComboBox_dbs.SelectedIndex == -1)
            {
                MessageBox.Show("please select one database");
            }
            else
            {
                //执行前先清空之前结果
                dataGridView_result.DataSource = null;

                string dbName = (string)toolStripComboBox_dbs.Text;
                if (sql.ToLower().StartsWith("select"))
                {
                    dbManagerService.ExecuteReader(GetConnStr(), dbName, sql);
                }
                else
                {
                    dbManagerService.ExecuteNonQuery(GetConnStr(), dbName, sql);
                }
            }
        }