I want to retrieve various information from my DB. But during testing my code I got the message:
Data is null. This method or property cannot be called on null values
There are nullable columns in my dB and I think those are causing the problem. Please someone help me to solve this problem. Here is my code:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using WpfDropDownNavigate.Models;
namespace WpfDropDownNavigate.Business
{
    public class MusteriBusiness
    {
        public static List<Musteriler> MusterileriGetir()
        {
            string sqltrtr = "select * from Customers";
            SqlDataReader reader = Helper.ExecuteReader(sqltrtr, CommandType.Text);
            List<Musteriler> musteriler = new List<Musteriler>();
            while (reader.Read())
            {
                musteriler.Add(new Musteriler
                {
                    MusteriID =reader.GetString(0),
                    FirmaAdi = reader.GetString(1),
                    SorumluKisi = reader.GetString(2),
                    Yetkisi = reader.GetString(3),
                    Adres = reader.GetString(4),
                    Sehir = reader.GetString(5),
                    Ulke = reader.GetString(6),
                    TelefonNo = reader.GetString(7),
                }) ;
            }
            reader.Close();
            return musteriler;
        }
        public static int MusteriGuncelle(string firmaAdi, string sorumluKisi, string yetkisi, string adres, string sehir, string ulke, string telefonNo,string musteriId)
        {
            string sqltrt = string.Format("update Customers set CompanyName='{0}',ContactName='{1}',ContactTitle='{2}',Address='{3}',City='{4}',Country='{5}',Phone='{6}' where CustomerID='{7}'", firmaAdi, sorumluKisi, yetkisi, adres, sehir, ulke, telefonNo, musteriId);
            return Helper.ExecuteNonQuery(sqltrt, CommandType.Text);
        }  
    }
}
using System;
using System.Collections.Generic;
using System.Text;
namespace WpfDropDownNavigate.Models
{
   public class Musteriler
   {
        public string FirmaAdi { get; set; }
        public string SorumluKisi { get; set; }
        public string Yetkisi { get; set; }
        public string Adres { get; set; }
        public string Sehir { get; set; }
        //public string Bolge { get; set; }
        //public string PostaKodu { get; set; }
        public string Ulke { get; set; }
        public string TelefonNo { get; set; }
        //public string FaxNo { get; set; }
        public string MusteriID { get; set; }
    }
}
 
     
    