I delete the edmx file and recreate it. Now I am getting this error. Can you tel
ID: 3583714 • Letter: I
Question
I delete the edmx file and recreate it. Now I am getting this error. Can you tell me how to I fix that?
Server Error in '/' Application.
The connection name 'GarageDBConnectionString' 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 'GarageDBConnectionString' was not found in the applications configuration or the connection string is empty.
Source Error:
Source File: c:UsersUserDocumentsVisual Studio 2013WebSitesGarageManagerPagesManagementManagement.aspx Line: 29
Stack Trace:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0
Management.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Management.aspx.cs" Inherits="Pages_Management_Management" %>
Add new Product
Add new ProductType
Management.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Pages_Management_Management : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void grdProducts_RowEditing(object sender, GridViewEditEventArgs e)
{
//Get selected row
GridViewRow row = grdProducts.Rows[e.NewEditIndex];
//Get Id of selected product
int rowId = Convert.ToInt32(row.Cells[1].Text);
//Redirect user to ManageProducts along with the selected rowId
Response.Redirect("~/Pages/Management/ManageProducts.aspx?id=" + rowId);
}
}
Web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
<buildProviders>
<add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
</buildProviders>
</compilation>
<httpRuntime targetFramework="4.5" />
</system.web>
<connectionStrings>
<add name="GarageDBEntities" connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlClient;provider connection string="data source=HARRIS-PC;initial catalog=GarageDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
Line 27: Line 28: Line 29: Line 30: Line 31:localhost: 6 Server Error in Application The connection name "GarageDBConnectionstring was not found in the applications configuration or the connection string is empty. Description An unhandled exception o ccurred during the execution of the cu ent web request. Please review he stac ace for more information about the error and w here it originated in the code. Exception Details: System InvalidoperationException: The connection name GarageDBConnectionString' w as not found in the applications configuration or the connection s ng is empty. Source Error: SortedDescendingHeaderStyle Backcolor "#575357" Line 27: Line 28 asp: GridView runat "server" Connection String ConnectionStrings GarageDBConnectionSt Line 29 Kasp:SqlDataSource ID sds Products Line 30
Explanation / Answer
1. At line number 29 you have specified GarageDBConnectionString .
2. In Web.config the connection string is specified as GarageDBEntities
The names at both the places should match , so you should either change GarageDBEntities to GarageDBConnectionString in Web.config or change GarageDBConnectionString to GarageDBEntities at line number 29 .
Please ensure that it is changed at all places in the code .
Thanks .
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.