连接字符串

VS中自建数据库的连接字符串:”DataSource=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\数据库名.mdf;Integrated Security=True;User Instance=True ”

WebConfig中两种不同的连接字符串:

sqlserver连接字符串
< connectionStrings >
        < add name = " DataBase " connectionString = " Server=.\sqlexpress;Database=数据库名; uid=sa;pwd=sa; " providerName = " System.Data.SqlClient " />
        < add name = " ConnectionString " connectionString = " DataSource=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\数据库名.mdf;Integrated Security=True; User Instance=True "             
         providerName
= " System.Data.SqlClient " />
</ connectionStrings >

引用:string myConnectionString = ConfigurationManager.ConnectionString["ConnectionString"].ConnectionString;

给大家提供一个所有类型的连接字符串的写法的查询网址:http://www.connectionstrings.com/

你可能感兴趣的:(字符串)