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

SQL Server连接字符串

时间:2017-03-02 21:48:06      阅读:512      评论:0      收藏:0      [点我收藏+]

标签:win   manage   connect   标记   string   source   initial   字符   config   

//windows身份验证1
            //string strCon = @"Data Source=.\sqlexpress;Initial Catalog=db1;Integrated Security=True;Pooling=False";
            
            //windows身份验证2
            //string strCon = @"server=.\sqlexpress;database=db1;Integrated Security=True;";

            //Sql Server身份验证1
            //string strCon = @"server=.\sqlexpress;database=db1;uid=sa;pwd=123456";

            //Sql Server身份验证2
            //string strCon = @"Data Source=.\sqlexpress;Initial Catalog=db1;User ID=sa;Password=123456;Pooling=False";

            /*
             从配置文件中读连接字符串
             在<configuration>标记中加上
             <connectionStrings>
                <add name="strCon" connectionString="server=.\sqlexpress;database=db1;uid=sa;pwd=123456"/> 
             </connectionStrings>
            */
            string strCon = ConfigurationManager.ConnectionStrings["strCon"].ConnectionString;

 

SQL Server连接字符串

标签:win   manage   connect   标记   string   source   initial   字符   config   

原文地址:http://www.cnblogs.com/beast-king/p/6492477.html

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