ARRRRHHHHHH !!!!! 這是我第二次碰到這個,grrrh - 浪費了幾個小時。
錯誤:
服務器遇到錯誤處理請求。例外消息是'不支持關鍵字:'初始目錄; MyDatabase;數據源'。'。查看服務器日誌獲取更多詳細信異常堆棧跟蹤是:
堆棧跟蹤:
at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at System.Data.SqlClient.SqlConnection..ctor(String connectionString, SqlCredential credential)
這是我的錯誤的連接字符串:
<add name="Production" connectionString="Password=Secret;Persist Security Info=True;User ID=MyUserID;Initial Catalog;MyDatabase;Data Source=aquickborwnfoxjumpedover.us-west-2.rds.amazonaws.com,1433" providerName="System.Data.SqlClient" />
看起來不錯吧? WRONG
最後,我發現了分號這裏:
Initial Catalog;MyDatabase
爲了校正它,我用等號:
Initial Catalog=MyDatabase
正確連接字符串:
<add name="ConnString" connectionString="Password=Secret;Persist Security Info=True;User ID=MyUserID;Initial Catalog=MyDatabase;Data Source=aquickborwnfoxjumpedover.us-west-2.rds.amazonaws.com,1433" providerName="System.Data.SqlClient" />
你使用的是什麼數據庫服務器(SQL Server,MySQL,Postgresql等)? –