时间:2021-07-01 10:21:17 帮助过:2人阅读
private void AnalysisConnectionstring() { string tempStr = “Data Source=192.168.2.123;Initial Catalog=caxastat;Persist Security Info=True;User ID=sa;Password=sa;Pooling=true;
Max Pool Size=40000;Connect Timeout=30”; string[] paras = tempStr.Split(‘;‘); foreach (string para in paras) { switch (para.Split(‘=‘)[0]) { case "Data Source": ServerName = para.Split(‘=‘)[1].Trim(); break; case "Initial Catalog": DataBase = para.Split(‘=‘)[1].Trim(); break; case "User ID": User = para.Split(‘=‘)[1].Trim(); break; case "Password": PassWord = para.Split(‘=‘)[1].Trim(); break; } } }
解析数据库连接字符串 (将Data Source、Initial Catalog、User ID、Password取出)
标签: