muratboy31 Posted June 9, 2015 Share Posted June 9, 2015 (edited) Arkadaşlar merhaba, veri tabınından veri çektiğimde eğer o tabloda istediğim koşullarda satır yoksa aşağıdaki hatayı alıyorum ! yardımcı olursanız çok sevinirim. bu şekilde bir çözüm buldum ama nekadar sağlıklıdır acaba ?; if (dtable.Rows[0].ItemArray[0].ToString() != "") Edited June 9, 2015 by muratboy31 Quote Link to comment Share on other sites More sharing options...
KintaRo Posted June 9, 2015 Share Posted June 9, 2015 O işi bence SQL kısmında halletmelisin. Örneğin MySQL'de IFNULL() fonksiyonu var. Eğer veri null ise yerine başka bir değer aktarabiliyorsun. SELECT IFNULL(tutar, 0) FROM fatura gibi. ama MSSQL'de nasıl bilmiyorum. Quote Link to comment Share on other sites More sharing options...
SimpsoN_Bart Posted June 9, 2015 Share Posted June 9, 2015 (edited) O işi bence SQL kısmında halletmelisin. Örneğin MySQL'de IFNULL() fonksiyonu var. Eğer veri null ise yerine başka bir değer aktarabiliyorsun. SELECT IFNULL(tutar, 0) FROM fatura gibi. ama MSSQL'de nasıl bilmiyorum. MSSQL de karşılığı ISNULL, Oracle da ise NVL dir. Örnek olarak; SELECT URUN_ID,FIYAT*(STOK+ISNULL(TUTAR,0)) FROM URUNLER Yinede kod olarak boş string kontrolü yapayım dersen boşluk kullanma çünkü boşlukta bir ASCII karakterdir çok sağlıklı değil bana kalırsa IsNullOrEmpty kullan daha güvenilirdir. using System; class Sample { public static void Main() { string s1 = "abcd"; string s2 = ""; string s3 = null; Console.WriteLine("String s1 {0}.", Test(s1)); Console.WriteLine("String s2 {0}.", Test(s2)); Console.WriteLine("String s3 {0}.", Test(s3)); } public static String Test(string s) { if (String.IsNullOrEmpty(s)) return "is null or empty"; else return String.Format("(\"{0}\") is neither null nor empty", s); } } // The example displays the following output: // String s1 ("abcd") is neither null nor empty. // String s2 is null or empty. // String s3 is null or empty. ////https://msdn.microsoft.com/en-us/library/system.string.isnullorempty(v=vs.110).aspx Edited June 9, 2015 by SimpsoN_Bart Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 9, 2015 Author Share Posted June 9, 2015 (edited) arkadaşlar alertControl kullanarak popup açmak istiyorum ve bu popup üzerinde 1 adet buton var, bu butonu kullanarak bir klasör açmak istiyorum ama beceremedim, aslında açılıyor ama tüm popuplarda aynı klasör açılıyor... yolu buton hint property sine ekliyorum veritabınından çekerken, başka veri ekleyecek yer bulamadım... aslında sorunun Process.Start("explorer.exe", @"" + alertControl1.Buttons[0].Hint); burdan kaynakladığını biliyorum çünkü sürekli aynı butonun hintini alıyor ama çözüm bulmadım... Edited June 9, 2015 by muratboy31 Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted June 9, 2015 Editor Share Posted June 9, 2015 Akşam eve geçtiğimde yardımcı olayım. Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 9, 2015 Author Share Posted June 9, 2015 (edited) teşekkürler pairs Edited June 9, 2015 by muratboy31 Quote Link to comment Share on other sites More sharing options...
KintaRo Posted June 9, 2015 Share Posted June 9, 2015 Process.Start("explorer.exe", "C:\\windows\\system32"); kod bu şekilde çalışıyor. .Hint'den gelen değer nedir? Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 9, 2015 Author Share Posted June 9, 2015 değerler bu şekilde klasör yolları, zaten açılıyor klasör sorun yok onda,... sorun kaç tane opup olursa olsun hep aynı klasör yolu açılıyor ama aslında buton üzerinde geldiğinde hintler doğru ama açarken hep aynı klasörü açıyor... foreach kullanarak ta denedim aynı ! public void TARIH_KONTROL() { SqlConnection mycon = new SqlConnection(); SqlCommand mycommand = new SqlCommand(); SqlDataAdapter adp = new SqlDataAdapter(mycommand); try { mycon.ConnectionString = Connect; mycon.Open(); mycommand.Connection = mycon; mycommand.CommandText = "sp_Tarih_Kontrol"; mycommand.CommandType = CommandType.StoredProcedure; DataTable dtable = new DataTable(); adp.Fill(dtable); foreach (DataRow dr in dtable.Rows) { AlertInfo info = new AlertInfo(dr[0].ToString(), dr[1].ToString()); foreach (AlertButton btn in alertControl1.Buttons) { btn.Hint = dr[2].ToString(); } alertControl1.Show(this, info); } } catch (Exception e) { MessageBox.Show(Convert.ToString(e)); } finally { mycon.Close(); } } void alertControl1_ButtonClick(object sender, AlertButtonClickEventArgs e) { if (e.ButtonName == "Ac") { foreach (AlertButton btn in alertControl1.Buttons) { Process.Start("explorer.exe", @"" + btn.Hint); } } } Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted June 9, 2015 Editor Share Posted June 9, 2015 Daha önce kullanmıştım bi bakarım akşam. Şirkette fırsat olmuyor bakmaya başka projeler var. Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 9, 2015 Author Share Posted June 9, 2015 Çözdüm teşekkürler arkadaşlar; void alertControl1_ButtonClick(object sender, AlertButtonClickEventArgs e) { if (e.ButtonName == "Ac") { Process.Start("explorer.exe", @"" + e.Button.Hint); } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.