「ConnectionString」修訂間的差異

出自ProgWiki
跳至導覽 跳至搜尋
 
(未顯示同一使用者於中間所作的 1 次修訂)
行 2: 行 2:
  
 
==技術文件==
 
==技術文件==
*[https://docs.microsoft.com/zh-tw/dotnet/framework/data/adonet/connection-string-syntax connection-string-syntax]
+
*[https://docs.microsoft.com/zh-tw/dotnet/framework/data/adonet/connection-string-syntax connection-string-syntax]
 
*[http://www.connectionstrings.com/ The Connection String Reference](各種資料庫的Connection Strings範例)
 
*[http://www.connectionstrings.com/ The Connection String Reference](各種資料庫的Connection Strings範例)
  
 
==應用==
 
==應用==
 
* 以下以ASP.NET於[[Web.config]]裡的使用方式記載,其他的格式請參照[http://www.connectionstrings.com]
 
* 以下以ASP.NET於[[Web.config]]裡的使用方式記載,其他的格式請參照[http://www.connectionstrings.com]
 +
* 如為 ASP.NET Core 則是把 ConnectionStrings 記錄在 appsettings.json
  
===MS-SQL Server===
+
===MS SQL Server===
 
<source lang="xml">
 
<source lang="xml">
 
<connectionStrings>
 
<connectionStrings>
 
<add name="myConnectionString"
 
<add name="myConnectionString"
  connectionString="Data Source=localhost;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;"
+
  connectionString="Data Source=localhost;Initial Catalog=myDB;User ID=myUsername;Password=myPassword;"
 
  providerName="System.Data.SqlClient"/>
 
  providerName="System.Data.SqlClient"/>
 
</connectionStrings>
 
</connectionStrings>
 
</source>
 
</source>
  
===MS-SQL Server Express===
+
===MS SQL Server Express===
 
<source lang="xml">
 
<source lang="xml">
 
<connectionStrings>
 
<connectionStrings>
 
<add name="myConnectionString"
 
<add name="myConnectionString"
  connectionString="Data Source=localhost\SQLExpress;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;"
+
  connectionString="Data Source=localhost\SQLExpress;Initial Catalog=myDB;User ID=myUsername;Password=myPassword;"
 
  providerName="System.Data.SqlClient"/>
 
  providerName="System.Data.SqlClient"/>
 
</connectionStrings>
 
</connectionStrings>
 
</source>
 
</source>
 +
 +
===MS SQL Server Express LocalDB===
 +
<source lang="xml">
 +
<connectionStrings>
 +
<add name="myConnectionString"
 +
connectionString="Server=(localdb)\\mssqllocaldb;Database=MyDB;Trusted_Connection=True;MultipleActiveResultSets=true"/>
 +
</connectionStrings>
 +
</source> 
  
 
===Oracle===
 
===Oracle===

於 2021年12月2日 (四) 14:17 的最新修訂

ConnectionString,參照:『維基百科~Connection_string

技術文件

應用

  • 以下以ASP.NET於Web.config裡的使用方式記載,其他的格式請參照[1]
  • 如為 ASP.NET Core 則是把 ConnectionStrings 記錄在 appsettings.json

MS SQL Server

<connectionStrings>
<add name="myConnectionString"
 connectionString="Data Source=localhost;Initial Catalog=myDB;User ID=myUsername;Password=myPassword;"
 providerName="System.Data.SqlClient"/>
</connectionStrings>

MS SQL Server Express

<connectionStrings>
<add name="myConnectionString"
 connectionString="Data Source=localhost\SQLExpress;Initial Catalog=myDB;User ID=myUsername;Password=myPassword;"
 providerName="System.Data.SqlClient"/>
</connectionStrings>

MS SQL Server Express LocalDB

<connectionStrings>
<add name="myConnectionString"
 connectionString="Server=(localdb)\\mssqllocaldb;Database=MyDB;Trusted_Connection=True;MultipleActiveResultSets=true"/>
</connectionStrings>

Oracle

<connectionStrings>
<add name="myConnectionString"
 connectionString="Data Source=MyOracleDB;Persist Security Info=True;User ID=myUsername;Password=myPassword;Unicode=True"
 providerName="System.Data.OracleClient"/>
</connectionStrings>

相關

自組ConnectionString