protected void btnMssqlSetup_Click(object sender, EventArgs e) { if ((string)Session["Type"] == "ToWeb") { try { string ConnectionString = "Data Source={0};Initial Catalog={1};User ID={2};Password={3};Integrated Security={4};"; ConnectionString = string.Format(ConnectionString, txtWebServer.Text, txtWebCatalog.Text, txtWebUser.Text, txtWebPass.Text, cbTrusted.Checked); SqlConnection SConn = new SqlConnection(ConnectionString); SConn.Open(); SConn.Close(); if (Install(ConnectionString, "")) { string strLang = Session["lang"].ToString(); Setup_Setup.SaveWebConfig(ConnectionString, "System.Data.SqlClient"); Session["Step"] = "Settings"; Response.Redirect("Default.aspx?Setup=OK&lang=" + strLang); } } catch (Exception ex) { divError.Visible = true; lblError.Text = ex.Message; } } else { string ConnectionString = "Data Source={0};User ID={1};Password={2};Integrated Security={3};"; ConnectionString = string.Format(ConnectionString, txtWebServer.Text, txtWebUser.Text, txtWebPass.Text, cbTrusted.Checked); SqlConnection SConn = new SqlConnection(ConnectionString); SqlCommand SComm = new SqlCommand("CREATE DATABASE [" + txtWebCatalog.Text + "]", SConn); try { SConn.Open(); SComm.ExecuteNonQuery(); if (Install(ConnectionString, string.Format("USE [{0}]\n", txtWebCatalog.Text))) { Setup_Setup.SaveWebConfig(ConnectionString + string.Format("Initial Catalog={0};", txtWebCatalog.Text), "System.Data.SqlClient"); Session["Step"] = "Settings"; Response.Redirect("Default.aspx?Setup=OK"); } } catch (Exception ex) { divError.Visible = true; lblError.Text = ex.Message; } finally { if (SConn.State == ConnectionState.Open) { SConn.Close(); } } } }
public void CreateXML(string ConnectionString) { Setup_Setup.SaveWebConfig(ConnectionString, "System.Data.OleDb"); }