AlHal2
asked on
Why do I need a connectionstring called LocalSQL Server?
I have about 8 web based GUIs.
My web.config file has 4 connection strings depending on which site the user logs into (dev, QA, production or disaster recovery).
The program looks at C:\inetpub\wwwroot\win.con fig to find out which site the user has logged into.
I’ve done this for my GUIs. Most of them authenticate by checking if the user’s TEN ID is in web.config. However, I have one GUI where the user must enter their name and a password that they choose.
I get an error message because there is no connection string named LocalSQLserver.
Since I have 4 connection strings (dev, qa, prod and DR), I deliberately made sure that none were called LocalSQLServer, so I could be sure that my GUI was connecting to the correct database.
Did you have a problem like this? If so, how did you get round it?
I know that localSQLServer appears in C:\Windows\Microsoft.NET\F ramework\v 2.0.50727\ CONFIG\Mac hine.confi g, but I don’t see why that matters.
My web.config file has 4 connection strings depending on which site the user logs into (dev, QA, production or disaster recovery).
The program looks at C:\inetpub\wwwroot\win.con
I’ve done this for my GUIs. Most of them authenticate by checking if the user’s TEN ID is in web.config. However, I have one GUI where the user must enter their name and a password that they choose.
I get an error message because there is no connection string named LocalSQLserver.
Since I have 4 connection strings (dev, qa, prod and DR), I deliberately made sure that none were called LocalSQLServer, so I could be sure that my GUI was connecting to the correct database.
Did you have a problem like this? If so, how did you get round it?
I know that localSQLServer appears in C:\Windows\Microsoft.NET\F
ASKER
It looks like the login control is calling the stored procedure aspnet_CheckSchemaVersion on localsqlserver. What will it do if I amend machine.config?
Is it possible to amend the login control instead?
I'm worried about other applications being affected.
Is it possible to amend the login control instead?
I'm worried about other applications being affected.
ASKER
I tried amending machine.config to test things, but was told that access has been denied.
Is there a way to amend the login control to look at the db that I specify in my web.config file for this application?
What were these lines supposed to achieve?
<connectionStrings>
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integr ated Security=SSPI;AttachDBFile name=|Data Directory| aspnetdb.m df;User Instance=true" providerName="System.Data. SqlClient" />
</connectionStrings>
Is there a way to amend the login control to look at the db that I specify in my web.config file for this application?
What were these lines supposed to achieve?
<connectionStrings>
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integr
</connectionStrings>
you can open the C:\Windows\Microsoft.NET\F ramework\v 2.0.50727\ CONFIG\Mac hine.confi g
and check the connectionstring for LocalSqlServer, see if it's pointing to a default database.
if it's pointg to |DataDirectory|aspnetdb.md f and you're not using it, you can remark the line and reboot your IIS for testing.
and check the connectionstring for LocalSqlServer, see if it's pointing to a default database.
if it's pointg to |DataDirectory|aspnetdb.md
>>Is there a way to amend the login control to look at the db that I specify in my web.config file for this application?
you need to open the file with Administrator right or perhaps your IIS services is not running.
you need to open the file with Administrator right or perhaps your IIS services is not running.
>>What were these lines supposed to achieve?
https://msdn.microsoft.com/en-us/library/ex526337(v=vs.100).aspx
Contains application data files including MDF files, XML files, as well as other data store files. The App_Data folder is used by ASP.NET 2.0 to store an application's local database, which can be used for maintaining membership and role information. For more information, see Introduction to Membership and Understanding Role Management.
https://msdn.microsoft.com/en-us/library/ex526337(v=vs.100).aspx
ASKER
>>Is there a way to amend the login control to look at the db that I specify in my web.config file for this application?
you need to open the file with Administrator right or perhaps your IIS services is not running.
Thanks for this. Are you referring to the file machine.config?
I was wondering if there is a property of the login control that can be changed. This would stop me having to change machine.config.
you need to open the file with Administrator right or perhaps your IIS services is not running.
Thanks for this. Are you referring to the file machine.config?
I was wondering if there is a property of the login control that can be changed. This would stop me having to change machine.config.
>>Are you referring to the file machine.config?
Yes
>>I was wondering if there is a property of the login control that can be changed. This would stop me having to change machine.config.
Alternatively, look for Configuration Editor in your IIS panel
and then select the connectionStrings from the dropdown list.
You should see Collection Count = 1. click on the "..." button to proceed to remove.
Yes
>>I was wondering if there is a property of the login control that can be changed. This would stop me having to change machine.config.
Alternatively, look for Configuration Editor in your IIS panel
and then select the connectionStrings from the dropdown list.
You should see Collection Count = 1. click on the "..." button to proceed to remove.
ASKER
I removed the connection string using IIS and got this error after I pressed login in the login control.
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)
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.
SQLExpress database file auto-creation error:
The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:
If the applications App_Data directory does not already exist, the web server account must have read and write access to the applications directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
If the applications App_Data directory already exists, the web server account only requires read and write access to the applications App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the applications App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server accounts credentials are used when creating the new database.
Sql Server Express must be installed on the machine.
The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.
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): 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.SqlI nternalCon nection.On Error(SqlE xception exception, Boolean breakConnection) +6299673
System.Data.SqlClient.TdsP arser.Thro wException AndWarning (TdsParser StateObjec t stateObj) +245
System.Data.SqlClient.TdsP arser.Conn ect(Server Info serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean withFailover) +536
System.Data.SqlClient.SqlI nternalCon nectionTds .AttemptOn eLogin(Ser verInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject, Boolean withFailover) +283
System.Data.SqlClient.SqlI nternalCon nectionTds .LoginNoFa ilover(Str ing host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +6319714
System.Data.SqlClient.SqlI nternalCon nectionTds .OpenLogin Enlist(Sql Connection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +6319672
System.Data.SqlClient.SqlI nternalCon nectionTds ..ctor(DbC onnectionP oolIdentit y identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +354
System.Data.SqlClient.SqlC onnectionF actory.Cre ateConnect ion(DbConn ectionOpti ons options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +300
System.Data.ProviderBase.D bConnectio nFactory.C reateNonPo oledConnec tion(DbCon nection owningConnection, DbConnectionPoolGroup poolGroup) +45
System.Data.ProviderBase.D bConnectio nFactory.G etConnecti on(DbConne ction owningConnection) +6324046
System.Data.ProviderBase.D bConnectio nClosed.Op enConnecti on(DbConne ction outerConnection, DbConnectionFactory connectionFactory) +6324359
System.Data.SqlClient.SqlC onnection. Open() +258
System.Web.Management.SqlS ervices.Ge tSqlConnec tion(Strin g server, String user, String password, Boolean trusted, String connectionString) +115
[HttpException (0x80004005): Unable to connect to SQL Server database.]
System.Web.Management.SqlS ervices.Ge tSqlConnec tion(Strin g server, String user, String password, Boolean trusted, String connectionString) +4041989
System.Web.Management.SqlS ervices.Se tupApplica tionServic es(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install) +159
System.Web.DataAccess.SqlC onnectionH elper.Crea teMdfFile( String fullFileName, String dataDir, String connectionString) +825
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)
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.
SQLExpress database file auto-creation error:
The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:
If the applications App_Data directory does not already exist, the web server account must have read and write access to the applications directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
If the applications App_Data directory already exists, the web server account only requires read and write access to the applications App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the applications App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server accounts credentials are used when creating the new database.
Sql Server Express must be installed on the machine.
The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.
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): 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.SqlI
System.Data.SqlClient.TdsP
System.Data.SqlClient.TdsP
System.Data.SqlClient.SqlI
System.Data.SqlClient.SqlI
System.Data.SqlClient.SqlI
System.Data.SqlClient.SqlI
System.Data.SqlClient.SqlC
System.Data.ProviderBase.D
System.Data.ProviderBase.D
System.Data.ProviderBase.D
System.Data.SqlClient.SqlC
System.Web.Management.SqlS
[HttpException (0x80004005): Unable to connect to SQL Server database.]
System.Web.Management.SqlS
System.Web.Management.SqlS
System.Web.DataAccess.SqlC
so are you using a local Sql Server Express instance using a database location within the applications App_Data directory? if yes you shouldn't removed that...
ASKER
How can I find out if I'm using a local Sql Server Express instance using a database location within the applications App_Data directory?
The App_data directory is empty.
The App_data directory is empty.
sorry that generally out of my knowledge as I didn't use App_data directory for application development.
but just think that that's some dependencies within your 8 web based GUIs.
but just think that that's some dependencies within your 8 web based GUIs.
ASKER
No problem.
Last question (I hope). Is it possible to see the coding behind the login control?
Last question (I hope). Is it possible to see the coding behind the login control?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks.
ASP.NET Configuration File Hierarchy and Inheritance
https://msdn.microsoft.com/en-us/library/ms178685.aspx
to resolve your issue, remove the relevant connectionstring setting from C:\Windows\Microsoft.NET\F