码迷,mamicode.com
首页 > 数据库 > 详细

解析数据库连接字符串 (将Data Source、Initial Catalog、User ID、Password取出)

时间:2016-07-13 22:26:43      阅读:373      评论:0      收藏:0      [点我收藏+]

标签:

  
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取出)

标签:

原文地址:http://www.cnblogs.com/zemax/p/5667643.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!