예제 #1
0
    /// <summary>
    /// 创建数据库
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void BtnCreateDateBase_Click(object sender, EventArgs e)
    {
        string sqlversion = DropSqlVersion.SelectedValue;
        string datasource = TxtDataSource.Text.ToString().Trim();
        string dataname   = TxtDataBase.Text.ToString();
        string username   = TxtUserID.Text.ToString();
        string userpwd    = TxtPwd.Value.ToString();
        string connstr    = "Data Source=" + datasource + ";Initial Catalog=" + dataname + ";User ID=" + username + ";Password="******"2000")
        {
            sqlpath = "../App_Data/ZoomLaCMS2000.sql";
        }
        else
        {
            sqlpath = "../App_Data/ZoomLaCMS2005.sql";
        }
        string filename   = Server.MapPath(sqlpath);
        string strmessage = "alert('数据库配置完成!')";// string.Empty;
        bool   flag       = false;

        if (Install.Connection(connstr) == null)
        {
            strmessage = "alert('数据库连接失败,可能如下原因: \\n1.数据库不存在!\\n2.用户或密码错误\\n3.用户不具有访问该数据库权限')";
        }
        else
        {
            if (!writexml(connstr))
            {
                strmessage = "alert('配置数据库失败!')";
            }
            else
            {
                if (!Install.CreateDataBase(filename, connstr))
                {
                    strmessage = "alert('用户无写入权限或数据库已经存在,执行sql脚本失败!')";
                }
                else
                {
                    flag = true;
                }
            }
        }
        if (!flag)
        {
            strmessage = "<script>" + strmessage + "; </script>";
            NextButtonStep4.Enabled = false;
        }
        else
        {
            strmessage = "<script>" + strmessage + "; </script>";//window.document.location.href=window.document.location.href

            NextButtonStep4.Enabled   = true;
            BtnCreateDateBase.Enabled = false;
        }

        if (!this.IsStartupScriptRegistered("check"))
        {
            Page.RegisterStartupScript("check", strmessage);
        }
    }