Hi, the code below successfully inserts a new user into my database:[code]Imports Microsoft.AspNet.IdentityImports Microsoft.AspNet.Identity.EntityFrameworkImports SystemImports System.LinqNamespace WebFormsIdentity Public Class Register Inherits System.Web.UI.Page Protected Sub CreateUser_Click(ByVal sender As Object, ByVal e As EventArgs) ' Default UserStore constructor uses the default connection string named: DefaultConnection Dim userStore = New UserStore(Of IdentityUser) Dim manager = New UserManager(Of IdentityUser)(userStore) Dim user = New IdentityUser user.UserName = UserName.Text Dim result As IdentityResult = manager.Create(user, Password.Text) Profile.PostCode = PostCode.Text Profile.VisitedOn = DateTime.Now Profile.Save() If result.Succeeded Then StatusMessage.Text = String.Format("User {0} was created successfully!", user.UserName) Else StatusMessage.Text = result.Errors.FirstOrDefault End If End Sub End ClassEnd Namespace[/code]However if I add the following code:[code]Profile.PostCode = PostCode.TextProfile.VisitedOn = DateTime.NowProfile.Save()[/code]and this in web.config:[code]<profile> <properties> <add name="PostCode" allowAnonymous="true"/> <add name="VisitedOn" type="System.DateTime" allowAnonymous="true"/> </properties> </profile>[/code]it gives the following error:[i]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: 26 - Error Locating Server/Instance Specified).[SqlException (0x80131904): 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: 26 - Error Locating Server/Instance Specified)] System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) +1394 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +664 System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) +57 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +1222 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +318 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +211 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +393 System.Data.SqlClient.SqlConnection.Open() +122 System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +83[HttpException (0x80004005): Unable to connect to SQL Server database.] System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +173 System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install) +113 System.Web.Management.SqlServices.Install(String database, String dbFileName, String connectionString) +51 System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString) +469[/i]Any ideas on what's causing this? I've tried restarting SQL Server, the connection must be fine as if I remove the few lines of code from the vb page it connects and can add a new user. If I add the code back in it suddenly can't connect.Thanks
↧