﻿
{"id":682,"date":"2012-05-28T12:37:42","date_gmt":"2012-05-28T12:37:42","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=682"},"modified":"2012-05-28T12:40:44","modified_gmt":"2012-05-28T12:40:44","slug":"cc-sharp-sorgu-sonucu-gelen-tabloyu-xml-formatinda-almak","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/cc-sharp-sorgu-sonucu-gelen-tabloyu-xml-formatinda-almak\/","title":{"rendered":"C#(C Sharp) &#8211; Sorgu Sonucu Gelen Tabloyu XML Format\u0131nda Almak"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Bu yaz\u0131mda, sorgulama sonucu d\u00f6nen tabloyu XML formatt\u0131nda almay\u0131 g\u00f6rece\u011fiz.<br \/>\n<!--more--><br \/>\nVeritaban\u0131 olarak Northwind kullanal\u0131m.<br \/>\n\u00d6rnek olarak \u00dcr\u00fcnler tablosunu XML formatta elde edelim.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            SqlConnection baglanti = new SqlConnection(&quot;Server=GEN\u00c7AY-GEN\u00c7AY;Database=Northwind;Trusted_Connection=True;&quot;);\r\n            SqlDataAdapter dap = new SqlDataAdapter(&quot;Select * from Urunler&quot;,baglanti);\r\n            DataSet ds = new DataSet();\r\n            dap.Fill(ds);\r\n            FileStream fs = new FileStream(&quot;Urunler.xml&quot;, FileMode.OpenOrCreate, FileAccess.Write);\r\n            ds.WriteXml(fs);\r\n            fs.Close();\r\n            MessageBox.Show(&quot;\u0130\u015flem Tamam&quot;);\r\n<\/pre>\n<p>Yukardaki kodlar\u0131 derleyip \u00e7al\u0131\u015ft\u0131rd\u0131\u011f\u0131m\u0131z zaman, mesaj kutusunda &#8220;\u0130\u015flem Tamam&#8221; yaz\u0131s\u0131yla kar\u015f\u0131la\u015f\u0131r\u0131z.&#8221;Urunler.xml&#8221; in olu\u015fturulaca\u011f\u0131 yolu belirmedik.O halde nereye olu\u015fturuldu diye sorarsan\u0131z e\u011fer,projenizin solution dosyas\u0131n\u0131n oldu\u011fu dizine gelip,&#8221;\\bin\\Debug&#8221; klas\u00f6rlerini takip ederseniz &#8220;Debug&#8221; isimli klas\u00f6r\u00fcn alt\u0131nda &#8220;Urunler.xml&#8221; oldu\u011funu g\u00f6r\u00fcrs\u00fcn\u00fcz.<\/p>\n<p>Genellikle yol verilmezse dosyalar bu klas\u00f6re eklenir.<\/p>\n<p>\u015eimdide Urunler.xml dosyam\u0131z\u0131 a\u00e7\u0131p bakal\u0131m.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;NewDataSet&gt;\r\n  &lt;Table&gt;\r\n    &lt;UrunID&gt;1&lt;\/UrunID&gt;\r\n    &lt;UrunAdi&gt;Chai&lt;\/UrunAdi&gt;\r\n    &lt;TedarikciID&gt;1&lt;\/TedarikciID&gt;\r\n    &lt;KategoriID&gt;1&lt;\/KategoriID&gt;\r\n    &lt;BirimdekiMiktar&gt;10 boxes x 20 bags&lt;\/BirimdekiMiktar&gt;\r\n    &lt;BirimFiyati&gt;19.8000&lt;\/BirimFiyati&gt;\r\n    &lt;HedefStokDuzeyi&gt;39&lt;\/HedefStokDuzeyi&gt;\r\n    &lt;YeniSatis&gt;0&lt;\/YeniSatis&gt;\r\n    &lt;EnAzYenidenSatisMikatari&gt;10&lt;\/EnAzYenidenSatisMikatari&gt;\r\n    &lt;Sonlandi&gt;false&lt;\/Sonlandi&gt;\r\n  &lt;\/Table&gt;\r\n  &lt;Table&gt;\r\n    &lt;UrunID&gt;2&lt;\/UrunID&gt;\r\n    &lt;UrunAdi&gt;Chang&lt;\/UrunAdi&gt;\r\n    &lt;TedarikciID&gt;1&lt;\/TedarikciID&gt;\r\n    &lt;KategoriID&gt;1&lt;\/KategoriID&gt;\r\n    &lt;BirimdekiMiktar&gt;24 - 12 oz bottles&lt;\/BirimdekiMiktar&gt;\r\n    &lt;BirimFiyati&gt;20.9000&lt;\/BirimFiyati&gt;\r\n    &lt;HedefStokDuzeyi&gt;17&lt;\/HedefStokDuzeyi&gt;\r\n    &lt;YeniSatis&gt;40&lt;\/YeniSatis&gt;\r\n    &lt;EnAzYenidenSatisMikatari&gt;25&lt;\/EnAzYenidenSatisMikatari&gt;\r\n    &lt;Sonlandi&gt;false&lt;\/Sonlandi&gt;\r\n  &lt;\/Table&gt;\r\n  &lt;Table&gt;\r\n    &lt;UrunID&gt;3&lt;\/UrunID&gt;\r\n    &lt;UrunAdi&gt;Aniseed Syrup&lt;\/UrunAdi&gt;\r\n.\r\n.\r\n.\r\n  &lt;\/Table&gt;\r\n&lt;\/NewDataSet&gt;\r\n<\/pre>\n<p>G\u00f6rd\u00fc\u011f\u00fcn\u00fcz \u00fczere root elemana &#8220;NewDataSet&#8221; ad\u0131n\u0131 vermi\u015f.\u00dcr\u00fcnler tablosundan ald\u0131\u011f\u0131 b\u00fct\u00fcn sat\u0131rlarada &#8220;Table&#8221; ismini vermi\u015f.<br \/>\n\u0130\u015fte sorgu sonucu gelen sonu\u00e7 tablosunu bu \u015fekilde XML format\u0131nda elde edebiliyoruz.<br \/>\nSonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere..<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar \ud83d\ude42<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Bu yaz\u0131mda, sorgulama sonucu d\u00f6nen tabloyu XML formatt\u0131nda almay\u0131 g\u00f6rece\u011fiz.<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,234],"tags":[752],"class_list":["post-682","post","type-post","status-publish","format-standard","hentry","category-c-sharp-c","category-xml","tag-xml"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=682"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/682\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}