English 中文(简体)
Asp.net Mvc 3联线
原标题:Asp.net Mvc 3 connection string issue

我刚刚为我的网站创造了一些东道空间。 然而,当我改变连接线向我的供应商服务器I时,发现了一个错误。

说明如下:

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

我收到这一错误:

Login failed for user  juydqjglrdwrhgsr .

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.Data.SqlClient.SqlException: Login failed for user  juydqjglrdwrhgsr .

Source Error: 


Line 32:                     <li>@Html.ActionLink("Home", "Index", "Home")</li>
Line 33:                     @{
Line 34:                         if(User.IsInRole("Admin"))
Line 35:                         {
Line 36:                          <li>@Html.ActionLink("Admin Controls", "Index", "Admin")</li> 

Source File: c:UsersAdministratorDocumentsVisual Studio 2010ProjectsTraxzTraxzViewsShared\_Layout.cshtml    Line: 34 

Stack Trace: 


[SqlException (0x80131904): Login failed for user  juydqjglrdwrhgsr .]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5064474
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275
   System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +183
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +239
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
   System.Data.SqlClient.SqlConnection.Open() +125
   System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +95
   System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +206
   System.Web.Security.SqlRoleProvider.GetRolesForUser(String username) +847
   WebMatrix.WebData.SimpleRoleProvider.GetRolesForUser(String username) +58
   System.Web.Security.RolePrincipal.IsInRole(String role) +182
   ASP._Page_Views_Shared__Layout_cshtml.Execute() in c:UsersAdministratorDocumentsVisual Studio 2010ProjectsTraxzTraxzViewsShared\_Layout.cshtml:34
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +272
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +187
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer) +52
   System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +203
   System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +42
   System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, HelperResult content) +45
   System.Web.WebPages.WebPageBase.Write(HelperResult result) +48
   System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +178
   System.Web.WebPages.WebPageBase.PopContext() +338
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +196
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
   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

我假设,这种联系方式是不正确的,任何人能否对此发表一些见解? 有必要使这一接待站开始运行,以便推进我的学校项目。

最新情况:我正在利用AppHarbor作为东道主,我一直在追捕这一问题,发现:

  If you take advantage of the Sequelizer MySQL and MS SQL Server add-ons, SQLSERVER_CONNECTION_STRING and SQLSERVER_URI settings will be injected into your application appSettings. SQLSERVER_CONNECTION_STRING_ALIAS will also be inserted if you add an alias. Further, the connection string will be placed in the connectionStrings element with name set to the alias if one is specified.

The uri is of the following format: sqlserver://username:password@hostname/databasename. If you want, you can create your own connection string (if, for example, you need a custom one for Entity Framework). Here s an example of building a standard connection string:

var uriString = ConfigurationManager.AppSettings["SQLSERVER_URI"];
var uri = new Uri(uriString);
var connectionString = new SqlConnectionStringBuilder
{
    DataSource = uri.Host,
    InitialCatalog = uri.AbsolutePath.Trim( / ),
    UserID = uri.UserInfo.Split( : ).First(),
    Password = uri.UserInfo.Split( : ).Last(),
}.ConnectionString;

我不知道这实际上意味着什么。 是否需要增加新的联系? 如果是这样,我如何为我所创立的实体绘制地图?

最佳回答

通过修改申请确定问题 服务连接:

<add name="TraxzDBEntities" connectionString="metadata=res://*/Models.DBModel.csdl|res://*/Models.DBModel.ssdl|res://*/Models.DBModel.msl;&#xD;&#xA;         provider=System.Data.SqlClient;&#xD;&#xA;         provider connection string=&quot;&#xD;&#xA;         Data Source=YOURPROVIDERDATASOURCE;&#xD;&#xA;         User ID=YourUserName; &#xD;&#xA;         Password=YourPassword;&#xD;&#xA;         Initial Catalog=YourCatalog;&#xD;&#xA;         Persist Security Info=True;&#xD;&#xA;      MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

然后,在我身上的“Dbcontext.context.tt”栏下,我们添加如下内容:

   string baseConnectionString = ConfigurationManager.ConnectionStrings["TraxzDBEntities"].ConnectionString;

    EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
    entityBuilder.Provider = "System.Data.SqlClient";
    entityBuilder.ProviderConnectionString = baseConnectionString;
    entityBuilder.Metadata = @"res://*/";

    return entityBuilder.ToString();
问题回答

暂无回答




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签