Entity Framework, and connection strings - entity-framework

I'm trying to deploy my .net website to a shared hosting server. I'm getting the following error when entity framework tries to connect to the database:
Server Error in '/' Application.
Login failed for user 'PHX3\Iusr_9086819'. 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 'PHX3\Iusr_9086819'.
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:
[SqlException (0x80131904): Login failed for user
'PHX3\Iusr_9086819'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +5061898
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
Here is my connection string, with sensitive data removed:
<add name="CoreEntities"
connectionString="
metadata=res://*/CoreModel.csdl|res://*/CoreModel.ssdl|res://*/CoreModel.msl;
provider=System.Data.SqlClient;
provider connection string='
Data Source=*****.db.*****.hostedresource.com;
Initial Catalog=kshoultz;
integrated security=True;
multipleactiveresultsets=True;
App=EntityFramework;
User ID=*****;
Password=*****;
Database=*****;
'"
providerName="System.Data.EntityClient" />

I think integrated security should be false - that means not to use a user id and password. Initial catalog is the name of the database - did they tell you the database was named kshoultz? (Could be, I don't know any different, but if you created a database and chose a name, that's the name you want to use). Has the password got any characters that aren't letters/numbers? You have to encode them, for example is your password is Love&Peace you have to say Love&Peace
Have you asked GoDaddy support?

Related

"The initialization of the persistence layer failed" for the RES console of the Business Rules service on Bluemix

When I open the Rule Execution Server console for the Business Rules service instance on Bluemix, I get this error:
The initialization of the persistence layer failed. Unexpected
exception during the build of DAO "persistence". null Cannot
connect to the database. [jcc][t4][2013][11249][4.17.29] Connection
authorization failure occurred. Reason: User ID or Password invalid.
ERRORCODE=-4214, SQLSTATE=28000 DSRA0010E: SQL State = 28000, Error
Code = -4,214 ilog.rules.res.console.IlrConsoleException: The
initialization of the persistence layer failed. at
ilog.rules.res.console.util.IlrModelManager.createResourceProviders(IlrModelManager.java:376)
at
ilog.rules.res.console.util.IlrModelManager.init(IlrModelManager.java:143)
at
ilog.rules.res.console.util.IlrConsoleInitializer.consoleInitialized(IlrConsoleInitializer.java:86)
at t ...
Empty the cache and refresh. If you still face the same issue, contact Bluemix support at http://ibm.biz/bluemixsupport and provide them with your Business Rules service instance ID.

Hang in System.Data.Entity.DbSet.Add()

I am following the Create an OData v4 Endpoint Using ASP.NET Web API 2.2 sample, and the Post() method implementation looks like this:
public async Task<IHttpActionResult> Post(Product product)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
db.Products.Add(product);
await db.SaveChangesAsync();
return Created(product);
}
However, when a Post request is received, Products.Add() hangs and never returns. No exception is thrown.
Under WinDBG I can see the following callstack:
System.Threading.Thread.Sleep
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist
System.Data.SqlClient.SqlInternalConnectionTds..ctor
System.Data.SqlClient.SqlConnectionFactory.CreateConnection
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection
System.Data.ProviderBase.DbConnectionPool.CreateObject
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest
System.Data.ProviderBase.DbConnectionPool.TryGetConnection
System.Data.ProviderBase.DbConnectionPool.TryGetConnection
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection
System.Data.SqlClient.SqlConnection.TryOpenInner
System.Runtime.InteropServices.SafeHandle.Dispose
System.Data.SqlClient.SqlConnection.TryOpen
System.Data.SqlClient.SqlConnection.Open
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute
System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection
System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection
System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifestToken
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken
System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked
System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken
System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo
System.Data.Entity.DbModelBuilder.Build
System.Data.Entity.Internal.LazyInternalContext.CreateModel
System.Data.Entity.Internal.LazyInternalContext.InitializeContext
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType
System.Data.Entity.DbSet.Add
ProductService.Controllers.ProductsController.Post
I am using EntityFramework 6.1.3.
If the Add() method is the one creating the connection with the database, should it be an *Async() method?
Update:
After porting the code from ASP.NET to Console Application, I caught the following exception:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in EntityFramework.dll
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.)
The problem is that the tutorial connection string is not valid anymore for Visual Studio 2015; Data Source=(localdb)\v11.0 needs to be replaced with Data Source=(localdb)\mssqllocaldb.
I.e.:
<add
name="ProductsContext"
connectionString="Data Source=(localdb)\mssqllocaldb;
Initial Catalog=ProductsContext; Integrated Security=True;
MultipleActiveResultSets=True;
AttachDbFilename=|DataDirectory|ProductsContext.mdf"
providerName="System.Data.SqlClient" />

Data Adapter in Ado.net

An attempt to attach an auto-named database for file C:\Users\vinod\Documents\Visual Studio 2013\WebSites\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
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.
from the exception message I guess that you are using LocalDb ... so you could just start Microsoft management studio and enter "(localdb)\v11.0" as server name ... then expand the "databases" node and remove everything that sounds like "aspnetdb.mdf" ...

Sync Framework 2.1 - Deleted row information cannot be accessed through the row

I am trying to sync SQL express to a central SQL 2008 r2 database. When I delete a row in the central database and try to sync it to the express database with a download-only scope, it throws the below error:
Deleted row information cannot be accessed through the row.
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.DeletedRowInaccessibleException: Deleted row information cannot be accessed through the row.
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:
[DeletedRowInaccessibleException: Deleted row information cannot be accessed through the row.]
Microsoft.Synchronization.ISyncSession.Start(CONFLICT_RESOLUTION_POLICY resolutionPolicy, _SYNC_SESSION_STATISTICS& pSyncSessionStatistics) +0
As mentioned in the comment I found the problem in the ChangesApplied event handler.
Changed the code to access row values from
table.Rows[i][j]
to
table.Rows[i][j, DataRowVersion.Original]
to fix it.

Crystal report 9.2, incorrect log on parameters

Background;
The Web application is developed for .Net framework 4.0. It has crystal report 9.2 integration. Application runs on Integrated Windows Authentication. The crystal reports are working fine when we execute, from solution running under Visual Studio 2010. When the same report are deployed to server (Web Server- OS: Windows Server 2003-SP2-32bit. DB Server- OS: Windows Server 2003-32bit) following error occurs, incorrect log on parameters. Crystal Report Runtime Engine for .net framework 4.0 has been installed in web server. Reports are configured to work on ODBC, System DSN with SQL Server driver. This drivers runs on SQL Server user account which has permission on database. There are no logon parameters passed from application. Just to verify, solution of passing the logon parameters from application is also tried, but the problem is not resolved.
Note: To resolve full access has been provided to IIS_WPG account on folder: C:\Windows\Temp, C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files and web application.
Server Error in '/XXXX' Application.
________________________________________
Error in File E:\WebApps\XXXX\Reports\CompanyStandard.rpt:
Unable to connect: incorrect log on parameters.
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: CrystalDecisions.CrystalReports.Engine.LogOnException: Error in File E:\WebApps\XXXX\Reports\CompanyStandard.rpt:
Unable to connect: incorrect log on parameters.
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:
[LogOnException: Error in File E:\WebApps\XXXX\Reports\CompanyStandard.rpt:
Unable to connect: incorrect log on parameters.]
. N(String -, EngineExceptionErrorID 0) +582
. I(Int16 !, Int32 ") +277
CrystalDecisions.CrystalReports.Engine.FormatEngine.GetPage(PageRequestContext reqContext) +429
CrystalDecisions.ReportSource.LocalReportSourceBase.GetPage(PageRequestContext pageReqContext) +172
CrystalDecisions.Web.ReportAgent.|(Boolean Z) +223
CrystalDecisions.Web.CrystalReportViewer.OnPreRender(EventArgs e) +165
System.Web.UI.Control.PreRenderRecursiveInternal() +103
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
You need to change the profile IIS is running under to a domain account or change your web.config file to impersonate the user. Otherwise you will need to apply logoninfo for the report.