Soru & Cevap

hataya düşmeyen fakat güncelleme de yapmayan update metodu ...

17.09.2015 - 12:03

merhaba. bir update metodum var. metod başarılı olarak dönüş yapıyor fakat MSSQL tablomda hiç bir alanı güncellemiyor. yardımcı olabilir misiniz? teşekkürler.

metodun adı:

updateSettings

BLL class:

​
public bool updateSettings(int ID, string backgroundColor, string textColorOnThePage, string inputBackgroundColor, string inputTextColor, string buttonTextColor, string buttonBackgroundColor, string logoText) 
{ 
return otPageLayout4EnterPagesDAL.updateSettings(ID, backgroundColor, textColorOnThePage, inputBackgroundColor, inputTextColor, buttonTextColor, buttonBackgroundColor, logoText);
 
}

​

DAL classımdaki karşılığı

  public bool updateSettings(int ID, string backgroundColor, string textColorOnThePage, string inputBackgroundColor, string inputTextColor, string buttonTextColor, string buttonBackgroundColor, string logoText)
        {
            try
            {
                using (var context = new KsEntities())
                {
                    context.ExecuteStoreCommand("UPDATE tPageLayout4EnterPages set backgroundColor ='" + backgroundColor + "', textColorForInputs ='" + inputTextColor + "', backgroundColorForInputs ='" + inputBackgroundColor + "', backgroundColorForButtons ='" + buttonBackgroundColor + "', textColorForButtons ='" + buttonTextColor + "', textColorOnThePage ='" + textColorOnThePage + "', textMessage ='" + logoText + "' WHERE ID = {0}", ID);
                }
                dc.SaveChanges();
                return true;

                
            }
            catch (Exception ex)
            {
                CommonHelper.MailAt("s.selcuk@hotmail.com", "error@abc.com", "" + ex.ToString() + "", "updateSettings");
                return false;
            }
        }

 

sayfamda çağırdığım kod parçası, yani metod:

tPageLayout4EnterPagesBLL otPageLayout4EnterPagesBLL; 

otPageLayout4EnterPagesBLL = new tPageLayout4EnterPagesBLL(); 

if (otPageLayout4EnterPagesBLL.updateSettings2(1, backgroundColor, textColorOnThePage, backgroundColorForInput, textColorForInput, textColorForButton, backgroundColorForButton, logotext) == true)

{ 

imgResultYes.Visible = true; lblResult.Text = "başarılı"; } else { lblMessageAsp.Text = "başarısız"; imgNoAsp.Visible = true; 

}

 

database tablosunun adı:

//tPageLayout4EnterPages

değiştirmek istediğim alanlar:

                //backgroundColor
                //textColorOnThePage

                //backgroundColorForInputs
                //textColorForInputs

                //textColorForButtons
                //backgroundColorForButtons

                //textMessage

 sayfamda başarılı scope'a düşüyor. fakat hiç bir alan güncellenmiyor.

MSSQL database de tüm alanların default değeri var. ve AllowNull'a izin vermiyorum. yani Allow Null seçiliği değil.

teşekkürler,

selçuk

3 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user m101
m101
19.11.2019 - 05:14

Direkt string halde query deneyin.


string querystr = "UPDATE Users SET User_FirstName=@User_FirstName, User_LastName=@User_LastName WHERE User_ID=@User_ID";