2012-03-10 31 views
0

我有一個問題,我正在建立一個網站。首先我做的是第一個表單頁面,它要求用戶填寫信息並將該信息添加到MySQL數據庫。有關網站在線時數據庫連接的錯誤

在該表單上,有一個綁定到數據庫的下拉列表。這種綁定使用實體模型發生。

要創建實體模型,我只是添加了新的ADO.NET Enity Data模型。然後我說從數據庫生成它。與我之前執行的數據庫(在線)的連接。所以我產生了一個模型。

元= RES:這過程中我的配置文件中創建一個新的行// /DAL.Model1.csdl|res:// /DAL.Model1.ssdl|res://*/DAL.Model1 .msl; provider = MySql.Data.MySqlClient; provider connection string =「server = 111.111.111.111; User Id = User; password = Password; Persist Security Info = True; port = 3212; database = database1」

So一切都很順利,我生成了一個模型,裏面有一張桌子。然後,我很容易地恢復數據,就像這樣:

using (var data = new dbdatingEntities()) 
    { 
     return data.countries.ToList(); 
    } 

這是錯誤發生,因爲在Page_Load中,我調用這個方法,返回我的國家名單...這似乎不順心的事。

當我測試它lokally它完美的作品,但是當我把它放在網上它已經工作了。

這是錯誤消息:

[ArgumentException的:初始化字符串的格式不符合規範開始於索引0] System.Data.Common.DbConnectionOptions.GetKeyValuePair(字符串的connectionString,的Int32 currentPosition, StringBuilder的緩衝液,布爾useOdbcRules,字符串&鍵名,字符串&鍵值)5066664 System.Data.Common.DbConnectionOptions.ParseInternal(哈希表parsetable,字符串的connectionString,布爾buildChain,哈希表同義詞,布爾firstKey)132 System.Data.Common .DbConnectionOptions..ctor(String connectionString,哈希表同義詞,布爾值useOd bcRules)+98 System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)+8119558 System.Data.EntityClient.EntityConnection..ctor(String connectionString)+81 System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString )+42 System.Data.Objects.ObjectContext..ctor(String connectionString,String defaultContainerName)+16 Model.Designer.cs中的Dating.DAL.dbEntities..ctor():34 Dating.DAL.RegisterFormHandler.ListCountries ()in RegisterFormHandler.cs:14 Dating.Registration.Page_Load(Object sender,EventArgs e)in Registration.aspx.cs:18 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,Object o,Object t,EventArgs e)+14 System.Web.Util.CalliE ()對象發件人,EventArgs e)+35 System.Web.UI.Control.OnLoad(EventArgs e)+91 System.Web.UI.Control.LoadRecursive()+74 System.Web.UI.Page .ProcessRequestMain(布爾includeStagesBeforeAsyncPoint,布爾includeStagesAfterAsyncPoint)+2207

任何幫助,歡迎提前致謝!

更新:即時嘗試,但仍然沒有成功。 我只是想知道我是唯一一個有這個問題的人嗎?因爲呃沒有太多的回覆幫助...但是如果有人有任何想法,請讓我知道!

更新: 問題解決了,似乎VS轉換我的配置文件,以便連接字符串有點破碎。現在沒問題。

回答

0

這是報價或"字符串=之間 「服務器111.111.111.111 =;用戶ID =用戶;密碼=密碼;堅持安全信息= TRUE;端口= 3212;數據庫=數據庫1」

+0

我不知道它是自動生成,它就像這樣" – Alnedru 2012-03-10 22:31:01

+0

@ user1002583也許你可以用單引號替換",比如string ='server = ...'在http://blogs.msdn.com/b/rickandy/archive/2008/上找到了這個。 12/09 /顯式連接字符串for ef.aspx – Silvermind 2012-03-10 22:47:20

+0

我試圖將其更改爲'this,但同樣的錯誤 – Alnedru 2012-03-10 23:21:47