取得connectionStrings属性「建议收藏」

取得connectionStrings属性「建议收藏」取得Webconfig文件连接数据库字符各个属性。代码 public string GetConnectionValue(string Keyword,string connectionString)        {            string[] aa = Keyword.Split(‘,’);                       string[] bb = co…

大家好,又见面了,我是你们的朋友全栈君。

取得Web config文件连接数据库字符各个属性。

取得connectionStrings属性「建议收藏」
取得connectionStrings属性「建议收藏」
代码

 
public
 
string
 GetConnectionValue(
string
 Keyword,
string
 connectionString)
        {

            

string
[] aa 
=
 Keyword.Split(

,

);           
            

string
[] bb 
=
 connectionString.Split(

;

);
            

string
 strTempValue 
=
 
string
.Empty;
            

foreach
 (
string
 b 
in
 bb)
            {

                

foreach
 (
string
 a 
in
 aa)
                {

                    

if
 (b.IndexOf(

=


<
 
0

continue
;  
                    

if
 (b.StartsWith(a, StringComparison.OrdinalIgnoreCase))
                        strTempValue 

=
 b.Substring(b.IndexOf(

=


+
 
1
);
                }
            }
            

return
 strTempValue;
        }

 

取得connectionStrings属性「建议收藏」
取得connectionStrings属性「建议收藏」
代码

        
public
 
string
 GetServerName()
        {

            

string
 key 
=
 

Data Source,Server,Address,Addr,Network Address

;
            

return
 GetConnectionValue(key);
        }

        
public
 
string
 GetDataBaseName()
        {

            

string
 key 
=
 

Initial Catalog,Database

;
            

return
 GetConnectionValue(key);
        }

        
public
 
string
 GetPassword()
        {

            

string
 key 
=
 

Password,Pwd

;
            

return
 GetConnectionValue(key);
        }

        
public
 
string
 GetUserId()
        {

            

string
 key 
=
 

User ID,uid

;
            

return
 GetConnectionValue(key);
        }

        
public
 
string
 GetPacketSize()
        {

            

string
 key 
=
 

Packet Size

;
            

return
 GetConnectionValue(key);
        }

        
public
 
string
 GetPooling()
        {

            

string
 key 
=
 

Pooling

;
            

return
 GetConnectionValue(key);
        }

        
public
 
string
 GetMaxPoolSize()
        {

            

string
 key 
=
 

Max Pool Size

;
            

return
 GetConnectionValue(key);
        }

        
public
 
string
 GetTrustedSecurity()
        {

            

string
 key 
=
 

Integrated Security,Trusted_Connection

;
            

return
 GetConnectionValue(key);
        }

        
public
 
bool
 IsTrustedSecurityConnection()
        {

            

string
 sScty 
=
 GetTrustedSecurity();
            

return
 (sScty 
==
 

SSPI

 
||
 sScty 
==
 

True

);
        }

        
public
 
bool
 IsAtLocalMachine()
        {

            

string
 sName 
=
 GetServerName();
            

return
 (sName 
==
 

127.0.0.1

 
||
 sName 
==
 

localhost

);
        }

 

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/143292.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • WinRAR 去除广告弹窗,简单4步亲测有效!

    WinRAR 去除广告弹窗,简单4步亲测有效!非常实用,亲测有效!下载这款破解小可爱软件:ResourceHacker软件很小,不要闲麻烦下载后打开WinRAR.exe,点击字符串表:修改第80:2052删除1272,然后保存。再次使用就没弹窗了,舒服了!参考:https://www.hack520.com/173.html…

    2022年5月20日
    29
  • 网站域名没有备案,可以访问嘛?

    网站域名没有备案,可以访问嘛?

    2021年9月25日
    198
  • python中concat函数的用法及示例

    python中concat函数的用法及示例concat方法相当于数据库中的全连接(UNIONALL),可以指定按某个轴进行连接,也可以指定连接的方式join(outer,inner只有这两种)。与数据库不同的是concat不会去重,要达到去重的效果可以使用drop_duplicates方法concat(objs,axis=0,join=’outer’,join_axes=None,ignore_index=False,k…

    2022年5月1日
    79
  • JDK1.8下载安装(Windows版)

    JDK1.8下载安装(Windows版)官网下载JDK在oracle上的下载地址:https://www.oracle.com/technetwork/java/javase/downloads/index.html,根据自己的需要,我这儿选择的是“JavaSE8u201/JavaSE8u202”,点击【JDK-DOWNLOAD】,打开第二张截图,如图选择接受,然后下载“JavaSEDevelopmentKit…

    2022年7月16日
    16
  • 有趣的python代码_python五角星代码

    有趣的python代码_python五角星代码原标题:使用Python代码的程序员也浪漫代码也浪漫:用Python放一场圣诞节烟花秀!天天敲代码的朋友,有没有想过代码也可以变得很酷炫又浪漫?今天就教大家用Python模拟出绽放的烟花庆祝昨晚法国队夺冠,工作之余也可以随时让程序为自己放一场烟花秀。这个有趣的小项目并不复杂,只需一点可视化技巧,100余行Python代码和程序库Tkinter,最后我们就能达到下面这个效果:学完本教程后,你也能做…

    2022年9月24日
    0
  • 软件激活成功教程官网_激活成功教程软件资源

    软件激活成功教程官网_激活成功教程软件资源[转]国内软件激活成功教程下载网站列表!Postedon2005-04-2511:17Laser.NET阅读(872)评论(1)编辑收藏国内最有信誉的激活成功教程下载网站,总能让你有意外收获。18DD资源中心:http://www.18dd.com7年:http://www.7year.com/热战软件园:http://soft.rezhan.comwqsky:http…

    2022年10月11日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号