Data Source = .\SQLEXPRESS;
sql server服务器名: . 本机
sql server实例名:SQLEXPRESS
AttachDbFilename =|DataDirectory|\Database1.mdf;
数据库路径
By default, the |DataDirectory| variable will be expanded as follow:
- For applications placed in a directory on the user machine, this will be the app's (.exe) folder.
- For apps running under ClickOnce, this will be a special data folder created by ClickOnce
- For Web apps, this will be the App_Data folder
Integrated Security = True;
使用windows认证,也就是运行可执行程序的用户来登录sql server
User Instance = true
SqlConnectionStringBuilder的UserInstance属性,对应connectionString中的User Instance ,该值指示是否将连接从默认的 SQL Server Express 实例重定向到在调用方帐户之下运行并且在运行时启动的实例。UserInstance=true,在这种情况下,SQLServerExpress为了把数据库附加到新的实例,建立一个新的进程,在打开连接的用户身份下运行。在ASP.NET应用程序中,这个用户是本地的ASPNET帐号或默认的NetworkService,这依赖于操作系统。为了安全地附加非系统管理员帐号(例如ASP.NET帐号)提供的数据库文件,建立一个独立的SQLServer用户实例是必要的。