EYoung
asked on
The connection name 'xxx' was not found in the applications configuration...
I am new to asp programming and am developing a simple intranet web site for our company. So far everything has been working well. I am developing the web site using vs/vb 2010 on my development computer, then copying the files to our intranet server in the wwwroot directory. The web.config file from my development computer is also copied each time.
Today I added a bound datagrid to the web site that brings in data from another server "tta-cwdw" and displays records from a table in a database called Retail in the grid. That works fine on my development computer, but when I copied the web site files to the wwwroot folder on the intranet server, this error is generated:
"The connection name 'ConnectionString_CWDW_Ret ail' was not found in the applications configuration or the connection string is empty."
The full error message is attached.
I have Googled this error message and found a number of references but none seem to help. Most say that I need to be sure that the ConnectionString is in the Web.Config file. I have confirmed this. See copy of the Web.config file.
Here is the section of code (Line 154...) that is causing the error:
<asp:SqlDataSource ID="DataSource_CWDW_Retail " runat="server"
ConnectionString="<%$ ConnectionStrings:Connecti onString_C WDW_Retail %>"
ProviderName="<%$ ConnectionStrings:Connecti onString_C WDW_Retail .ProviderN ame %>"
SelectCommand="SELECT * FROM [ReportSubscriptions] ORDER BY [RecipientEmail]">
</asp:SqlDataSource>
Because I am new to asp development, I think this is probably an easy error to fix.
Would appreciate help with this. Thank you.
Today I added a bound datagrid to the web site that brings in data from another server "tta-cwdw" and displays records from a table in a database called Retail in the grid. That works fine on my development computer, but when I copied the web site files to the wwwroot folder on the intranet server, this error is generated:
"The connection name 'ConnectionString_CWDW_Ret
The full error message is attached.
I have Googled this error message and found a number of references but none seem to help. Most say that I need to be sure that the ConnectionString is in the Web.Config file. I have confirmed this. See copy of the Web.config file.
Here is the section of code (Line 154...) that is causing the error:
<asp:SqlDataSource ID="DataSource_CWDW_Retail
ConnectionString="<%$ ConnectionStrings:Connecti
ProviderName="<%$ ConnectionStrings:Connecti
SelectCommand="SELECT * FROM [ReportSubscriptions] ORDER BY [RecipientEmail]">
</asp:SqlDataSource>
Because I am new to asp development, I think this is probably an easy error to fix.
Would appreciate help with this. Thank you.
Full error message:
Server Error in '/' Application.
--------------------------------------------------------------------------------
The connection name 'ConnectionString_CWDW_Retail' was not found in the applications configuration or the connection string is empty.
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.InvalidOperationException: The connection name 'ConnectionString_CWDW_Retail' was not found in the applications configuration or the connection string is empty.
Source Error:
Line 152: </asp:GridView>
Line 153:
Line 154: <asp:SqlDataSource ID="DataSource_CWDW_Retail" runat="server"
Line 155: ConnectionString="<%$ ConnectionStrings:ConnectionString_CWDW_Retail %>"
Line 156: ProviderName="<%$ ConnectionStrings:ConnectionString_CWDW_Retail.ProviderName %>"
Source File: C:\inetpub\wwwroot\Retail_Reports.aspx Line: 154
Stack Trace:
[InvalidOperationException: The connection name 'ConnectionString_CWDW_Retail' was not found in the applications configuration or the connection string is empty.]
System.Web.Compilation.ConnectionStringsExpressionBuilder.GetConnectionString(String connectionStringName) +4400005
ASP.retail_reports_aspx.__BuildControlDataSource_CWDW_Retail() in C:\inetpub\wwwroot\Retail_Reports.aspx:154
ASP.retail_reports_aspx.__BuildControlpnlRecipients() in C:\inetpub\wwwroot\Retail_Reports.aspx:83
ASP.retail_reports_aspx.__BuildControl__control4(Control __ctrl) in C:\inetpub\wwwroot\Retail_Reports.aspx:28
AjaxControlToolkit.TabPanel.OnInit(EventArgs e) in d:\hg\act\Server\AjaxControlToolkit\Tabs\TabPanel.cs:185
System.Web.UI.Control.InitRecursive(Control namingContainer) +133
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1954
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
=========================================================================
copy of Web.config file
=========================================================================
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings>
<add name="ConnectionString_CWDW_Retail" connectionString="Provider=SQLOLEDB;Data Source=TTA-CWDW;Integrated Security=SSPI;Initial Catalog=Retail"
providerName="System.Data.OleDb" />
</connectionStrings>
<system.web>
<!--
Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
-->
<compilation debug="true" strict="true" explicit="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Generic"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Linq"/>
<add namespace="System.Xml.Linq"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
</system.web>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
</configuration>
ASKER
I don't see any file on my development computer or the web server that has a .config extension other than the web.config.
One odd thing that happens each time I copy all of the files from my development computer to the web server is that the Web.config file drops the extension ".config". I manually have to rename the file from web to web.config on the web server.
One odd thing that happens each time I copy all of the files from my development computer to the web server is that the Web.config file drops the extension ".config". I manually have to rename the file from web to web.config on the web server.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
1. I think your suggestion fixed part of the problem I was having. I unchecked the "Hide extensions for known file types" option. Now I see the extension. In fact, my renaming it from web to web.config before caused the actual file name to become web.config.config which caused IIS to not find web.config. So that is progress. Thank you.
2. Now with the file just named web.config, I am getting a "Login failed for user..." error. I suspect we are making progress here. Below is the full error message I am now getting:
Server Error in '/' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Login failed for user 'TTACORP\TTA-INTRANET$'.
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.OleDb.OleDbExc eption: Login failed for user 'TTACORP\TTA-INTRANET$'.
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:
[OleDbException (0x80040e4d): Login failed for user 'TTACORP\TTA-INTRANET$'.]
System.Data.OleDb.OleDbCon nectionInt ernal..cto r(OleDbCon nectionStr ing constr, OleDbConnection connection) +1777302
System.Data.OleDb.OleDbCon nectionFac tory.Creat eConnectio n(DbConnec tionOption s options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +100
System.Data.ProviderBase.D bConnectio nFactory.C reateNonPo oledConnec tion(DbCon nection owningConnection, DbConnectionPoolGroup poolGroup) +43
System.Data.ProviderBase.D bConnectio nFactory.G etConnecti on(DbConne ction owningConnection) +6296143
System.Data.ProviderBase.D bConnectio nClosed.Op enConnecti on(DbConne ction outerConnection, DbConnectionFactory connectionFactory) +6296606
System.Data.OleDb.OleDbCon nection.Op en() +48
System.Data.Common.DbDataA dapter.Fil lInternal( DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +292
System.Data.Common.DbDataA dapter.Fil l(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +420
System.Data.Common.DbDataA dapter.Fil l(DataSet dataSet, String srcTable) +312
System.Web.UI.WebControls. SqlDataSou rceView.Ex ecuteSelec t(DataSour ceSelectAr guments arguments) +3368519
System.Web.UI.DataSourceVi ew.Select( DataSource SelectArgu ments arguments, DataSourceViewSelectCallba ck callback) +28
System.Web.UI.WebControls. DataBoundC ontrol.Per formSelect () +274
System.Web.UI.WebControls. BaseDataBo undControl .EnsureDat aBound() +105
System.Web.UI.WebControls. CompositeD ataBoundCo ntrol.Crea teChildCon trols() +183
System.Web.UI.Control.Ensu reChildCon trols() +182
System.Web.UI.Control.PreR enderRecur siveIntern al() +60
System.Web.UI.Control.PreR enderRecur siveIntern al() +222
System.Web.UI.Control.PreR enderRecur siveIntern al() +222
System.Web.UI.Control.PreR enderRecur siveIntern al() +222
System.Web.UI.Control.PreR enderRecur siveIntern al() +222
System.Web.UI.Control.PreR enderRecur siveIntern al() +222
System.Web.UI.Control.PreR enderRecur siveIntern al() +222
System.Web.UI.Control.PreR enderRecur siveIntern al() +222
System.Web.UI.Control.PreR enderRecur siveIntern al() +222
System.Web.UI.Control.PreR enderRecur siveIntern al() +222
System.Web.UI.Control.PreR enderRecur siveIntern al() +222
System.Web.UI.Page.Process RequestMai n(Boolean includeStagesBeforeAsyncPo int, Boolean includeStagesAfterAsyncPoi nt) +4185
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
2. Now with the file just named web.config, I am getting a "Login failed for user..." error. I suspect we are making progress here. Below is the full error message I am now getting:
Server Error in '/' Application.
--------------------------
Login failed for user 'TTACORP\TTA-INTRANET$'.
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.OleDb.OleDbExc
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:
[OleDbException (0x80040e4d): Login failed for user 'TTACORP\TTA-INTRANET$'.]
System.Data.OleDb.OleDbCon
System.Data.OleDb.OleDbCon
System.Data.ProviderBase.D
System.Data.ProviderBase.D
System.Data.ProviderBase.D
System.Data.OleDb.OleDbCon
System.Data.Common.DbDataA
System.Data.Common.DbDataA
System.Data.Common.DbDataA
System.Web.UI.WebControls.
System.Web.UI.DataSourceVi
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.Control.Ensu
System.Web.UI.Control.PreR
System.Web.UI.Control.PreR
System.Web.UI.Control.PreR
System.Web.UI.Control.PreR
System.Web.UI.Control.PreR
System.Web.UI.Control.PreR
System.Web.UI.Control.PreR
System.Web.UI.Control.PreR
System.Web.UI.Control.PreR
System.Web.UI.Control.PreR
System.Web.UI.Control.PreR
System.Web.UI.Page.Process
--------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
It seems that the database login you are using doesn't have enough privelege.
ASKER
I do not get this login failure error when running the web app from my development computer in the VS 2010 IDE. The error occurs when I run the app directly from the web server or call it from my development computer using IE.
I suspect when I run it from my development computer, I don't have login errors because I am an administrator in the company and so when I run the app from my development computer in the vs 2010 IDE, I am using my login name and password.
But when I run the web app using IE from my development computer or directly from the intranet server, the login failure message occurs because the intranet server is trying to log into the SQL Server tta-cwdw possibly using the anonymous login name?
At any rate, it seems like there is a security issue here when the intranet computer (ttacorp/tta-intranet) tries to access the SQL Server (tta-cwdw) to get the records for the grid.
Thank you for your help.
I suspect when I run it from my development computer, I don't have login errors because I am an administrator in the company and so when I run the app from my development computer in the vs 2010 IDE, I am using my login name and password.
But when I run the web app using IE from my development computer or directly from the intranet server, the login failure message occurs because the intranet server is trying to log into the SQL Server tta-cwdw possibly using the anonymous login name?
At any rate, it seems like there is a security issue here when the intranet computer (ttacorp/tta-intranet) tries to access the SQL Server (tta-cwdw) to get the records for the grid.
Thank you for your help.
ASKER
Should I try to add more priveleges to ttacorp\tta-intranet, or should I change the login rights in SQL Server (tta-cwdw) to possibly allow tta-intranet to get in?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Set the login you are using as db owner on the database you are using:
Go to SQL Server Management Studio --> Login as administrator --> Right Click Login you are using --> Properties --> Database Mapping --> Select the database --> Check db owner (from below) --> OK
Go to SQL Server Management Studio --> Login as administrator --> Right Click Login you are using --> Properties --> Database Mapping --> Select the database --> Check db owner (from below) --> OK
ASKER
DoNetChano:
1. Not sure what login "name" to check on SQL. The intranet server is called tta-intranet and the error message referred to 'TTACORP\TTA-INTRANET$', but I don't know what name the intranet asp application is using to attempt its login to SQL Server on tta-cwdw to access the Retail database.
2. Below is the connection string code in the ASP application. As you can see there is no password field in the code. I guess it is just using the login name I use on my development computer to log into the SQL Server on tta-cwdw? It works when I run the asp application from my development computer but fails when running it from the intranet.
Here is the connection string code in my asp.net 4.0 application. As you can see there is no user or password:
<asp:SqlDataSource ID="DataSource_CWDW_Retail " runat="server"
ConnectionString="<%$ ConnectionStrings:Connecti onString_C WDW_Retail %>"
ProviderName="<%$ ConnectionStrings:Connecti onString_C WDW_Retail .ProviderN ame %>"
SelectCommand="SELECT * FROM [ReportSubscriptions] ORDER BY [RecipientEmail]">
</asp:SqlDataSource>
bitref:
1. It looks like I am the owner of the database "Retail". In SQL SMS it shows "TTACORP\eyoung" as the db_owner of the Retail database. That is me. This has not changed as I created the database Retail originally. I can run the asp successfully from my development computer, I think, because I am logged into it using my admin name eyoung.
2. Do you think the problem with logging via the intranet is due to the tta-intranet server using a different user name when attempting to log into SQL Server? I doubt tta-intranet is using my eyoung login name to login into the SQL Server (tta-cwdw) when attempting to read the Retail database.
Here is an overview:
My development computer name is tta-NTWK-133xp2 and is running W/XP
The intranet computer name is tta-intranet and is running IIS 7.5
The SQL Server computer name is tta-cwdw and is running SQL Server 2005
All three computers are physically separate boxes.
When I run the ASP application from my development computer it runs correctly and does access tta-cwdw to retrieve the SQL database "Retail". That all works fine from my development computer using VS 2010.
However, after copying the ASP application to the intranet web server (tta-intranet) and then attempting to run it from IE8 on either tta-intranet or IE8 on my development computer, the login error appears.
That seems to indicate that the error is due to the intranet computer not having rights to access the Retail database on tta-cwdw. So that leads me to think that the login name the intranet computer is using is different from my login name.
Thank you for the help and assistance.
1. Not sure what login "name" to check on SQL. The intranet server is called tta-intranet and the error message referred to 'TTACORP\TTA-INTRANET$', but I don't know what name the intranet asp application is using to attempt its login to SQL Server on tta-cwdw to access the Retail database.
2. Below is the connection string code in the ASP application. As you can see there is no password field in the code. I guess it is just using the login name I use on my development computer to log into the SQL Server on tta-cwdw? It works when I run the asp application from my development computer but fails when running it from the intranet.
Here is the connection string code in my asp.net 4.0 application. As you can see there is no user or password:
<asp:SqlDataSource ID="DataSource_CWDW_Retail
ConnectionString="<%$ ConnectionStrings:Connecti
ProviderName="<%$ ConnectionStrings:Connecti
SelectCommand="SELECT * FROM [ReportSubscriptions] ORDER BY [RecipientEmail]">
</asp:SqlDataSource>
bitref:
1. It looks like I am the owner of the database "Retail". In SQL SMS it shows "TTACORP\eyoung" as the db_owner of the Retail database. That is me. This has not changed as I created the database Retail originally. I can run the asp successfully from my development computer, I think, because I am logged into it using my admin name eyoung.
2. Do you think the problem with logging via the intranet is due to the tta-intranet server using a different user name when attempting to log into SQL Server? I doubt tta-intranet is using my eyoung login name to login into the SQL Server (tta-cwdw) when attempting to read the Retail database.
Here is an overview:
My development computer name is tta-NTWK-133xp2 and is running W/XP
The intranet computer name is tta-intranet and is running IIS 7.5
The SQL Server computer name is tta-cwdw and is running SQL Server 2005
All three computers are physically separate boxes.
When I run the ASP application from my development computer it runs correctly and does access tta-cwdw to retrieve the SQL database "Retail". That all works fine from my development computer using VS 2010.
However, after copying the ASP application to the intranet web server (tta-intranet) and then attempting to run it from IE8 on either tta-intranet or IE8 on my development computer, the login error appears.
That seems to indicate that the error is due to the intranet computer not having rights to access the Retail database on tta-cwdw. So that leads me to think that the login name the intranet computer is using is different from my login name.
Thank you for the help and assistance.
ASKER
OK, the problem is fixed. Apparently the intranet server (tta-intranet) uses its own name "TTACORP\tta-intranet$" to log into the SQL Server tta-cwdw. Once I added "TTACORP\tta-intranet$" to the list of Logins under the SQL Security tab on tta-cwdw, the application worked fine.
Thanks to everyone who helped. It is much appreciated.
Thanks to everyone who helped. It is much appreciated.
Make sure you don't have any file with .config extension in your application folder.