Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net MVC3 SQL Connection String

I am creating an app on APPHARBOR and I have an entity model for querying the SQL server. The following String is givving me error:

<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" />

Here is the stack trace: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Keyword not supported: 'server'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[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

I wasted numerous hours on this, and idk what is wrong.. Please help.

like image 713
Aziz Avatar asked Nov 16 '11 23:11

Aziz


People also ask

How do I find my LocalDB connection string?

Start LocalDB and connect to LocalDB To connect to a specific database by using the file name, connect using a connection string similar to Server=(LocalDB)\MSSQLLocalDB;Integrated Security=true;AttachDbFileName=D:\Data\MyDB1. mdf .

How do I create a SQL Server connection string in Visual Studio?

Open Visual Studio. Right-click on "Data Connections" and select "Add Connection" or click on the "Connect to Database" icon. Select the "Use SQL Server Authentication" radio button. Then submit the Username and password.

What is SQL connection string in C#?

The connection string is an expression that contains the parameters required for the applications to connect a database server. In terms of SQL Server, connection strings include the server instance, database name, authentication details, and some other settings to communicate with the database server.


2 Answers

There is seemingly some other connect string being used here. Are you setting a connect string in code as well? in your asp.net mvc project what are all the connect strings in the web.config? Just the above?

Search your entire solution for the word "server"

like image 88
Adam Tuliper Avatar answered Sep 28 '22 05:09

Adam Tuliper


To add to Adam's suggestion (which is probably the answer), in your code snippet you don't have a ; after Password=** (maybe you do in the real code though). And you are also using both username and password and Integrated Security=true; which doesn't make sense to me since Integrated Security=true; means to use the currently logged on user.

like image 35
Tom Chantler Avatar answered Sep 28 '22 03:09

Tom Chantler