Ejemplo n.º 1
0
        private void btn_exec_Click(object sender, EventArgs e)
        {
            #region 输入判断
            if (richTextBox1.Text == "")
            {
                MessageBox.Show("请输入sql脚本!", "提示");
                return;
            }
            if (txt_user.Text == "")
            {
                MessageBox.Show("请先读取配置!", "提示");
                return;
            }
            //if (txt_pwd.Text == "")
            //{
            //    MessageBox.Show("请输入密码!", "提示");
            //    return;
            //}
            if (txt_ip.Text == "")
            {
                MessageBox.Show("请先读取配置!", "提示");
                return;
            }
            if (txt_db.Text == "")
            {
                MessageBox.Show("请先读取配置!", "提示");
                return;
            }
            #endregion

            #region 日志记录
            loginbiz.WriteLog(this.Name.Trim(), "【" + Program.username + "】" + "在电脑【" + ma.HostName() + "】上执行了sql脚本!IP:" + Program.hostip, Program.username);
            #endregion

            string str_sql = richTextBox1.Text.Trim();
            try
            {
                biz.ExecSql(str_sql);
                richTextBox2.Text = "执行脚本成功!";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "异常提示");
                richTextBox2.Text = ex.ToString();
            }
        }