sqlserver,sqlite,access數(shù)據(jù)庫鏈接字符串整理
更新時間:2014年07月28日 10:08:25 投稿:whsnow
本節(jié)主要整理sqlserver,sqlite,access數(shù)據(jù)庫鏈接字符串,有需要的朋友可以參考下
SqlServer:string connection = "server=32.1.1.48;database=數(shù)據(jù)庫名;user=sa;password=sa2008";
access 2007:
//無密碼的連接字符串 string conStr = "Provider=Microsoft.Ace.OleDb.12.0;Data Source=E://111.accdb;Persist Security Info=False"; //有密碼的連接字符串 string conStr = "Provider=Microsoft.Ace.OleDb.12.0;Data Source=E://111.accdb;Jet OleDb:DataBase Password=111";
access 2003:
//無密碼的連接字符串 string conStr = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=E://111.mdb;Persist Security Info=False"; //有密碼的連接字符串 string conStr = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=E://111.mdb;Jet OleDb:DataBase Password=111";
鏈接access數(shù)據(jù)庫若出現(xiàn) 無法啟動應用程序 工作組信息文件丟失 有可能是鏈接字符串鏈接不正確
Sqlite :
string conStr = "Data Source=E://111.db;Password=111";
在使用SQLite時需要添加一個引用 System.Data.SQLite,C#在運行時候會提示混合模式程序集是針對“v2.0.50727”版的運行時生成的,在沒有配置其他信息的情況下,無法在 4.0 運行時中加載該程序集 ,這個問題可以在app.config中添加一個配置節(jié):startup
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup>