SqlConnectionStringBuilder提供了一个很好的构建SQL连接字串的方式。不多说,见代码:

           SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder
{
DataSource = "(localdb)\\MSSQLLocalDB",
InitialCatalog = "UserManage",
//UserID = "adb",
//Password = "aaa",
IntegratedSecurity = true,//是否使用windows登录相同的用户名和密码
MultipleActiveResultSets = true,//是否允许一次连接多次查询
ApplicationName="EntityFramework"//标识应用程序名称,可以自定义,供在SQL跟踪调试时用
};
string connStr = builder.ConnectionString;

上面代码得到的连接字串为:data source=(localdb)\\MSSQLLocalDB;initial catalog=UserManage;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework

Namespace:   System.Data.SqlClient
Assembly:  System.Data (in System.Data.dll)

SqlConnectionStringBuilder的用法的更多相关文章

  1. 使用SqlConnectionStringBuilder构造数据库连接字符串

    在实际开发过程中,很多时候会拷贝一个现有的数据库连接字符串,修改对应的数据库名.用户名.密码等配置成新的数据库连接字符串.但是有时候我们需要增加一些额外的配置,比如超时时间,最大连接池等,此时我们可以 ...

  2. EditText 基本用法

    title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...

  3. jquery插件的用法之cookie 插件

    一.使用cookie 插件 插件官方网站下载地址:http://plugins.jquery.com/cookie/ cookie 插件的用法比较简单,直接粘贴下面代码示例: //生成一个cookie ...

  4. Java中的Socket的用法

                                   Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...

  5. [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法

    一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...

  6. python enumerate 用法

    A new built-in function, enumerate() , will make certain loops a bit clearer. enumerate(thing) , whe ...

  7. [转载]Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结

    本文对Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法进行了详细的总结,需要的朋友可以参考下,希望对大家有所帮助. 详细解读Jquery各Ajax函数: ...

  8. 【JavaScript】innerHTML、innerText和outerHTML的用法区别

    用法: <div id="test">   <span style="color:red">test1</span> tes ...

  9. chattr用法

    [root@localhost tmp]# umask 0022 一.chattr用法 1.创建空文件attrtest,然后删除,提示无法删除,因为有隐藏文件 [root@localhost tmp] ...

随机推荐

  1. leetcode 859. Buddy Strings

    Given two strings A and B of lowercase letters, return true if and only if we can swap two letters i ...

  2. 20145239杜文超 《Java程序设计》实验二 Java面向对象程序设计实验报告

    20145239 <Java程序设计>实验二 Java面向对象程序设计实验报告 实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉S. ...

  3. php设计模式课程---9、桥接模式是什么

    php设计模式课程---9.桥接模式是什么 一.总结 一句话总结: 一个类没干完,另外一个类接着给它干完 实质是类的拼接,也就是用类的组合代替了类的继承,因为类的组合可以有很多种方式,所以桥接就是类的 ...

  4. listen 71

    Creepy People Leave You Cold Jack Nicholson, playing the crazed caretaker in The Shining, makes me r ...

  5. base64编码方式

    一.编码的两大方式: 在python3.x中,字符串编码分为unicode和bytes两大类编码方式. 直接书写s='中国人',这种方式定义的编码方式为unicode,是通用的方式. 另一种是byte ...

  6. linux命令学习笔记(52):ifconfig命令

    许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有 一个类似的工具,也就是ifconfig (interfaces config).通 ...

  7. ACM学习历程——HDU5202 Rikka with string(dfs,回文字符串)

    Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...

  8. 【LeetCode】282. Expression Add Operators

    题目: Given a string that contains only digits 0-9 and a target value, return all possibilities to add ...

  9. Digging-贪心

    When it comes to the Maya Civilization, we can quickly remind of a term called the end of the world. ...

  10. 演讲:对 2000 多亿条数据做一次 group by 需要多久?

    http://2017.qconbeijing.com/presentation/646?utm_source=weibo&utm_medium=infoq&utm_campaign= ...