日期:2014-05-20 浏览次数:20940 次
protected void Button1_Click(object sender, EventArgs e) { if (CeShi())//这是测试下输入的是否正确 { if (txtDatabaseName.Text.Trim()=="kj249") { try { string name=DbSqlHelper.kj249();//这个是dbsqlhelp帮助类里方法、返回连接字符串 if (name != null&&name!="") { Session["Name"] = "kj249"; lblShow.Text = string.Format("<span style=color:Red;font-size:20px>数据库切换成功</span>"); Response.Redirect("setup.aspx"); } } catch (Exception ex) { lblShow.Text = string.Format("<span style=color:Red;font-size:20px>数据库切换失败</span>"); lblSql.Text = ex.Message; } } else { try { string name=DbSqlHelper.boram_web(); if (name != null && name != "") { Session["Name"] = "boram"; lblShow.Text = string.Format("<span style=color:Red;font-size:20px>数据库切换成功</span>"); Response.Redirect("index.aspx"); } } catch (Exception ex) { lblShow.Text = string.Format("<span style=color:Red;font-size:20px>数据库切换失败</span>"); lblSql.Text = ex.Message; } }
public class DbSqlHelper { protected static string connectionString = ConfigurationManager.ConnectionStrings["boram_web"].ConnectionString; public static string boram_web() { connectionString = ConfigurationManager.ConnectionStrings["boram_web"].ConnectionString; return connectionString; } public static string kj249() { connectionString = ConfigurationManager.ConnectionStrings["kj249"].ConnectionString; return connectionString; }
public class Handler : IHttpHandler { CollieryBll bll = new CollieryBll(); public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; string name = context.Request["Name"]; if (name == null) { context.Response.Write(JsonTree().ToString()); } else if (name == "kj249") { context.Response.Write(Tree249().ToString()); } else { context.Response.Write(JsonTree().ToString()); } }