Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
fix db connection bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Pau Doltra committed Sep 13, 2017
1 parent e9fb1ea commit 3e706fc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions eShopLegacyMVCSolution/src/eShopLegacyMVC/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="CatalogDBContext" connectionString="Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=CatalogDBContext-20170810122408; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|CatalogDBContext-20170810122408.mdf" providerName="System.Data.SqlClient" />
<!-- <add name="CatalogDBContext" connectionString="Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word" providerName="System.Data.SqlClient" /> -->
<add name="CatalogDBContext" connectionString="Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb; Integrated Security=True; MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ public partial class Edit : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)
{
var productId = Convert.ToInt32(Page.RouteData.Values["id"]);
product = CatalogService.FindCatalogItem(productId);

if (!Page.IsPostBack)
{

var productId = Convert.ToInt32(Page.RouteData.Values["id"]);
product = CatalogService.FindCatalogItem(productId);

BrandDropDownList.DataSource = CatalogService.GetCatalogBrands();
BrandDropDownList.SelectedValue = product.CatalogBrandId.ToString();

Expand All @@ -48,7 +49,7 @@ protected void Save_Click(object sender, EventArgs e)
{
var catalogItem = new CatalogItem
{
Id = product.Id,
Id = Convert.ToInt32(Page.RouteData.Values["id"]),
Name = Name.Text,
Description = Description.Text,
CatalogBrandId = int.Parse(BrandDropDownList.SelectedValue),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<!--<add name="CatalogDBContext" connectionString="Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=CatalogDBContext-20170810122408; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|CatalogDBContext-20170810122408.mdf" providerName="System.Data.SqlClient" />-->
<add name="CatalogDBContext" connectionString="Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word" providerName="System.Data.SqlClient" />
<add name="CatalogDBContext" connectionString="Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb; Integrated Security=True; MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="UseMockData" value="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public partial class Edit : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)
{
var productId = Convert.ToInt32(Page.RouteData.Values["id"]);
product = CatalogService.FindCatalogItem(productId);

if (!Page.IsPostBack)
{
var productId = Convert.ToInt32(Page.RouteData.Values["id"]);
product = CatalogService.FindCatalogItem(productId);
BrandDropDownList.DataSource = CatalogService.GetCatalogBrands();
BrandDropDownList.SelectedValue = product.CatalogBrandId.ToString();

Expand All @@ -48,7 +48,7 @@ protected void Save_Click(object sender, EventArgs e)
{
var catalogItem = new CatalogItem
{
Id = product.Id,
Id = Convert.ToInt32(Page.RouteData.Values["id"]),
Name = Name.Text,
Description = Description.Text,
CatalogBrandId = int.Parse(BrandDropDownList.SelectedValue),
Expand Down

0 comments on commit 3e706fc

Please sign in to comment.