6

我正在APPHARBOR上創建一個應用程序,我有一個用於查詢SQL服務器的實體模型。以下字符串是givving我的錯誤:ASP.Net MVC3 SQL連接字符串

<add name="TraxzDBEntities" 
      connectionString="metadata=res://*/Models.DBModel.csdl|res://*/Models.DBModel.ssdl|res://*/Models.DBModel.msl; 
      provider=System.Data.SqlClient; 
      provider connection string='Data Source=d5d3955e-1183-4e10-8892-9f9d005af0a8.sqlserver.sequelizer.com; 
      User ID=**; 
      Password=**; 
      Initial Catalog=dbd5d3955e11834e1088929f9d005af0a8;Integrated Security=true; 
      MultipleActiveResultSets=True'" 
     providerName="System.Data.EntityClient" /> 

這裏是堆棧跟蹤: 說明:在當前Web請求的執行過程中發生未處理的異常。請查看堆棧跟蹤以獲取有關該錯誤的更多信息以及源代碼的位置。

異常詳細信息:System.ArgumentException:不支持的關鍵字:'server'。

源錯誤:

在當前web請求的執行過程中生成未處理的異常。關於異常的來源和位置的信息可以使用下面的異常堆棧跟蹤來標識。

堆棧跟蹤:

[ArgumentException: Keyword not supported: 'server'.] 
    System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +5110868 
    System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +98 
    System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +112 
    System.Data.EntityClient.EntityConnection..ctor(String connectionString) +77 
    System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, ConnectionStringSettingsCollection connectionStrings) +309 
    System.Data.Entity.Internal.LazyInternalConnection.Initialize() +52 
    System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel() +10 
    System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +265 
    System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18 
    System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +62 
    System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15 
    System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +37 
    System.Linq.Queryable.Where(IQueryable`1 source, Expression`1 predicate) +63 
    Traxz.Models.TraxzRepository.getListOfUserExerciseSessions(Guid userID) in d:\temp\lhvy3m2t.j0d\input\Traxz\Models\TraxzRepository.cs:77 
    Traxz.Controllers.ExerciseSessionController.listSessions(Nullable`1 page, Nullable`1 SessionID) in d:\temp\lhvy3m2t.j0d\input\Traxz\Controllers\ExerciseSessionController.cs:34 
    lambda_method(Closure , ControllerBase , Object[]) +164 
    System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17 
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27 
    System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263 
    System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191 
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343 
    System.Web.Mvc.Controller.ExecuteCore() +116 
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97 
    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10 
    System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37 
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21 
    System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12 
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 
    System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50 
    System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7 
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22 
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60 
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8963149 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184 

我浪費在這無數個小時,IDK的什麼是錯的。請幫助。

回答

4

這裏似乎有一些其他連接字符串在使用。你是否也在代碼中設置連接字符串?你的asp.net mvc項目中的 什麼是web.config中的所有連接字符串?只是以上?

搜索您的整個解決方案單詞「服務器」

+0

同意,我發生了這種情況,它最終成爲設計人員引用的另一個連接字符串。 –

+0

嗯,我已閱讀了一些關於appharbor的文檔,看起來他們強制你構造一個動態連接字符串 - 但我測試了這個字符串,並且它正確地查詢了託管的sql服務器。 – Aziz

+0

然後,您將忽略重要細節。這是什麼動態連接字符串?我敢冒險說,由於上述錯誤,它不能正常工作。 –

1

要添加到亞當的建議(這可能是答案),在您的代碼段,你沒有;Password=**(也許你在做但真正的代碼)。而且您還使用用戶名和密碼以及Integrated Security=true;,這對我沒有意義,因爲Integrated Security=true;表示使用當前登錄的用戶。

+0

我試過刪除Integrated Security = true; - 但是這沒有效果。 – Aziz