C# 常用数据库连接字符串, SQL Server, MySQL, Oracle, Access mdb

C# 常用数据库连接字符串, SQL Server, MySQL, Oracle, Access mdb
// SqlServer-Windows Authentication
string connectionString = "Data Source=127.0.0.1,1433;Initial Catalog=TestDB;connect timeout=10;Integrated Security=True";
// SqlServer-Account & Password
string connectionString = "Data Source=127.0.0.1,1433;Initial Catalog=TestDB;uid=sa;pwd=123456";

// MySql-Account & Password
string connectionString = "server=127.0.0.1;port=3306;database=TestDB;charset=utf8;user id=root;password=123456;pooling=false;";

// Oracle-Account & Password
string connectionString = "Data Source=(DESCRIPTION=(ADDRESS =(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1522))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=TestDB)));User Id=scott;Password=123456";

// Access-connect mdb
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\Test.mdb" + ";Jet OLEDB:Database Password=123456;Persist Security Info=False";
// Access-connect accdb
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\Test.accdb" + ";Jet OLEDB:Database Password=123456;Persist Security Info=False";
// Access-connect mdb - ASP.NET(App_Data)
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"|DataDirectory|\\TestDB.mdb\";Jet OLEDB:database password=987654321;Persist Security Info=False";
// Access-connect accdb - ASP.NET(App_Data)
string connectionString = "Provider=Microsoft.Jet.OLEDB.12.0;Data Source=\"|DataDirectory|\\TestDB.accdb\";Jet OLEDB:database password=987654321;Persist Security Info=False";
// Access-connect mdb - ASP.NET
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath("~//Test.mdb") + ";Jet OLEDB:Database Password=123456;Persist Security Info=False";
// Access-connect accdb - ASP.NET
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath("~//Test.accdb") + ";Jet OLEDB:Database Password=123456;Persist Security Info=False";


作者最新文章
ASP.NET aspx获取服务器信息, 操作系统, .NET版本, IIS版本
C# Unix转换本地时间, Unix时间戳转换DateTime
C# 获取Unix时间戳
C# DateTime.Ticks 转换为 DateTime
C# 数字转换字符串左边补0, 数字前补0的方法