Kolay gelsin.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Xml;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public class baglanti
{
SqlConnection conn;
SqlDataAdapter dtAdapter, sAdapter;
SqlCommand Cmd,sorgu;
public SqlDataReader Oku;
XmlTextReader veriOku;
public baglanti()
{
//conn = new SqlConnection(@"Data Source=ONDER-33\SQLEXPRESS;Initial Catalog=samatya;Integrated Security=True");
conn = new SqlConnection("workstation id=;packet size=4096;user id=;pwd=;data source=;persist security info=False;initial catalog=samatya");
}
public void ac()
{
conn.Open();
}
public void kapat()
{
conn.Close();
}
public double kayitSayisi(string s)
{
sorgu = new SqlCommand(s, conn);
int sayi = (int)sorgu.ExecuteScalar();
return Convert.ToDouble(sayi);
}
public void Calistir(string Sorgu)
{
Cmd = new SqlCommand(Sorgu,conn);
if (Sorgu.Substring(0, 6) == "select" || Sorgu.Substring(0, 6) == "SELECT")
{
Oku = Cmd.ExecuteReader();
}
else
{
Cmd.ExecuteNonQuery();
}
}
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Xml;
public partial class sitemap : System.Web.UI.Page
{
baglanti b,c;
kontrol k;
veriislem v;
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = "text/html";
XmlTextWriter objX = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
objX.WriteStartDocument();
objX.WriteStartElement("urlset");
objX.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
objX.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
objX.WriteAttributeString("xsi:schemaLocation", "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd ");
objX.WriteStartElement("url");
objX.WriteElementString("loc", "http://localhost/");
objX.WriteEndElement();
k = new kontrol();
v = new veriislem();
c = new baglanti();
c.ac();
c.Calistir("select * from kategoriler order by id desc");
while (c.Oku.Read())
{
objX.WriteStartElement("url");
objX.WriteElementString("loc", "http://localhost/kategori.aspx?id=" + c.Oku["id"].ToString() + "-" + k.degistir(c.Oku["baslik"].ToString()));
objX.WriteEndElement();
}
c.kapat();
b = new baglanti();
b.ac();
b.Calistir("select id,baslik from konular order by id desc");
while (b.Oku.Read())
{
objX.WriteStartElement("url");
objX.WriteElementString("loc", "http://http://localhost/detay.aspx?id=" + b.Oku["id"].ToString() + "-" + k.degistir(b.Oku["baslik"].ToString()));
objX.WriteEndElement();
}
b.kapat();
objX.WriteEndDocument();
objX.Flush();
objX.Close();
Response.End();
}
}