Beispiel #1
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.m_strCon == "")
                {
                    MessageBox.Show("请先测试连接!");
                    return;
                }

                SqlConnection sCon = new SqlConnection(this.m_strCon);
                sCon.Open();
                SqlCommand sCmd = new SqlCommand();
                sCmd.Connection  = sCon;
                sCmd.CommandText = "use master";
                sCmd.ExecuteNonQuery();
                string strSql = String.Format("select count(*) from sysdatabases where name='{0}'", "dbBengZhan");
                sCmd.CommandText = strSql;
                string strCount = sCmd.ExecuteScalar().ToString();
                if (strCount != "0")
                {
                    MessageBox.Show("数据库已存在,请先进入系统再进行备份还原!");
                    return;
                }

                frmBackRestoreDB frmBackResDB = new frmBackRestoreDB();
                frmBackResDB.m_bIni     = true;
                frmBackResDB.m_bRestore = true;
                frmBackResDB.ShowDialog();
                sCon.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            try
            {
                    if(this.m_strCon=="")
                    {
                        MessageBox.Show("���Ȳ������ӣ�");
                        return;
                    }

                    SqlConnection sCon=new SqlConnection(this.m_strCon);
                sCon.Open();
                SqlCommand sCmd=new SqlCommand();
                sCmd.Connection=sCon;
                sCmd.CommandText="use master";
                sCmd.ExecuteNonQuery();
                string strSql=String.Format("select count(*) from sysdatabases where name='{0}'","dbBengZhan");
                sCmd.CommandText=strSql;
                string strCount=sCmd.ExecuteScalar().ToString();
                if(strCount!="0")
                {
                    MessageBox.Show("���ݿ��Ѵ��ڣ����Ƚ���ϵͳ�ٽ��б��ݻ�ԭ��");
                    return;
                }

            frmBackRestoreDB frmBackResDB=new frmBackRestoreDB();
            frmBackResDB.m_bIni=true;
                frmBackResDB.m_bRestore=true;
            frmBackResDB.ShowDialog();
                sCon.Close();

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }