SQL İLE HEPSİ

SİLME

protected void Button3_Click(object sender, EventArgs e)

    {

        SqlConnection bag = new SqlConnection(@"Data Source=.\SQLEXPRESS; Initial Catalog=personelbilg; Integrated Security=True;");

        bag.Open();

        SqlCommand co = new SqlCommand();

        co.Connection = bag;

        String S1, S2, S3, S4, S5, S6, S7, S8;

        S1 = TextBox1.Text;

        S2 = TextBox2.Text;

        S3 = TextBox3.Text;

        S4 = TextBox4.Text;

        S5 = TextBox5.Text;

        S6 = TextBox6.Text;

        S7 = TextBox7.Text;

        S8 = TextBox8.Text;

        co.CommandText = "DELETE from personeltbl where pertc=\'" + S1 + "\' or ad=\'" + S2 + "\' or soyad=\'" + S3 + "\' or tel=\'" + S4 + "\' or adres=\'" + S5 + "\' or dogtar=\'" + S6 + "\' or boy=\'" + S7 + "\' or maas=\'" + S8 + "\'";

        co.ExecuteNonQuery();

        TextBox1.Text = "";

        TextBox2.Text = "";

        TextBox3.Text = "";

        TextBox4.Text = "";

        TextBox5.Text = "";

        TextBox6.Text = "";

        TextBox7.Text = "";

        TextBox8.Text = "";

        co.CommandText = "Select * from personeltbl";

        SqlDataAdapter ad = new SqlDataAdapter();

        ad.SelectCommand = co;

        DataSet ds = new DataSet();

        ad.Fill(ds, "personeltbl");

        ListBox1.Items.Clear();

        foreach (DataTable table in ds.Tables)

            foreach (DataRow kyt in table.Rows)

                ListBox1.Items.Add(kyt["pertc"] + " "

                    + kyt["ad"] + " " + kyt["soyad"] + " " + kyt["tel"] + " " + kyt["adres"] + " " + kyt["dogtar"] + " " + kyt["boy"] + " " + kyt["maas"]);

        bag.Close();

    }

 

 

 

 

 

 

KAYIT YAPMA

protected void Button1_Click(object sender, EventArgs e)

    {

 

        SqlConnection bag = new SqlConnection(@"Data Source=.\SQLEXPRESS; Initial Catalog=personelbilg; Integrated Security=True;");

        bag.Open();

        SqlCommand co = new SqlCommand();

        co.Connection =bag;

        String S1, S2, S3, S4, S5, S6, S7, S8;

        S1 = TextBox1.Text;

        S2 = TextBox2.Text;

        S3 = TextBox3.Text;

        S4 = TextBox4.Text;

        S5 = TextBox5.Text;

        S6 = TextBox6.Text;

        S7 = TextBox7.Text;

        S8 = TextBox8.Text;

        co.CommandText = "INSERT INTO personeltbl(pertc,ad,soyad,tel,adres,dogtar,boy,maas)"

                     + "VALUES (\'" + S1 + "\',\'" + S2 + "\',\'" + S3 + "\',\'" + S4 + "\',\'" + S5 + "\',\'" + S6 + "\',\'" + S7 + "\',\'" + S8 + "\')";

        co.ExecuteNonQuery();

        TextBox1.Text = "";

        TextBox2.Text = "";

        TextBox3.Text = "";

        TextBox4.Text = "";

        TextBox5.Text = "";

        TextBox6.Text = "";

        TextBox7.Text = "";

        TextBox8.Text = "";

        co.CommandText = "Select * from personeltbl";

        SqlDataAdapter ad = new SqlDataAdapter();

        ad.SelectCommand = co;

        DataSet ds = new DataSet();

        ad.Fill(ds, "personeltbl");

        ListBox1.Items.Clear();

        foreach (DataTable table in ds.Tables)

            foreach (DataRow kyt in table.Rows)

                ListBox1.Items.Add(kyt["pertc"] + " "

                    + kyt["ad"] + " " + kyt["soyad"] + " " + kyt["tel"] + " " + kyt["adres"] + " " + kyt["dogtar"] + " " + kyt["boy"] + " " + kyt["maas"]);

        bag.Close();

       

    }

 

 

 

 

 

ARAMA

protected void Button2_Click(object sender, EventArgs e)

    {

        SqlConnection bag = new SqlConnection(@"Data Source=.\SQLEXPRESS; Initial Catalog=personelbilg; Integrated Security=True;");

        bag.Open();

        SqlCommand co = new SqlCommand();

        co.Connection = bag;

        String S1;

        S1 = TextBox1.Text;

        TextBox1.Text = ""; // ARAMADA OR KULLANILIR

        TextBox2.Text = "";

        TextBox3.Text = "";

        TextBox4.Text = "";

        TextBox5.Text = "";

        TextBox6.Text = "";

        TextBox7.Text = "";

        TextBox8.Text = "";

 

        co.CommandText = "Select * from personeltbl where pertc=\'" + S1 + "\'";

        SqlDataAdapter ad = new SqlDataAdapter();

        ad.SelectCommand = co;

        DataSet ds = new DataSet();

        ad.Fill(ds, "personeltbl");

        ListBox1.Items.Clear();

        foreach (DataTable table in ds.Tables)

            foreach (DataRow kyt in table.Rows)

                ListBox1.Items.Add(kyt["pertc"] + " "

                    + kyt["ad"] + " " + kyt["soyad"] + " " + kyt["tel"] + " " + kyt["adres"] + " " + kyt["dogtar"] + " " + kyt["boy"] + " " + kyt["maas"]);

        bag.Close();

    }

LİSTELEME

protected void Button5_Click(object sender, EventArgs e)

    {

        SqlConnection bag = new SqlConnection(@"Data Source=.\SQLEXPRESS; Initial Catalog=personelbilg; Integrated Security=True;");

        bag.Open();

        SqlCommand co = new SqlCommand();

        co.Connection = bag;

        co.CommandText = "Select * from personeltbl";

        SqlDataAdapter ad = new SqlDataAdapter();

        ad.SelectCommand = co;

        DataSet ds = new DataSet();

        ad.Fill(ds, "personeltbl");

        ListBox1.Items.Clear();

        foreach (DataTable table in ds.Tables)

            foreach (DataRow kyt in table.Rows)

                ListBox1.Items.Add(kyt["pertc"] + " "

                    + kyt["ad"] + " " + kyt["soyad"] + " " + kyt["tel"] + " " + kyt["adres"] + " " + kyt["dogtar"] + " " + kyt["boy"] + " " + kyt["maas"]);

        bag.Close();

    }

 

GÜNCELLEME

protected void Button4_Click(object sender, EventArgs e)

    {

        SqlConnection bag = new SqlConnection(@"Data Source=.\SQLEXPRESS; Initial Catalog=personelbilg; Integrated Security=True;");

        bag.Open();

        SqlCommand co = new SqlCommand();

        co.Connection = bag;

        String S1, S2, S3, S4, S5, S6, S7, S8;

 

        S1 = TextBox1.Text;

        S2 = TextBox2.Text;

        S3 = TextBox3.Text;

        S4 = TextBox4.Text;

        S5 = TextBox5.Text;

        S6 = TextBox6.Text;

        S7 = TextBox7.Text;

        S8 = TextBox8.Text;

       

       

        if (S2 != "")

        {

            co.CommandText = "UPDATE personeltbl SET ad=\'" + S2 + "\' where pertc=\'" + S1 + "\'";

            co.ExecuteNonQuery();

        }

        if (S3 != "")

        {

            co.CommandText = "UPDATE personeltbl SET soyad=\'" + S3 + "\' where pertc=\'" + S1 + "\'";

            co.ExecuteNonQuery();

        }

        if (S4 != "")

        {

            co.CommandText = "UPDATE personeltbl SET tel=\'" + S4 + "\' where pertc=\'" + S1 + "\'";

            co.ExecuteNonQuery();

        }

        if (S5 != "")

        {

            co.CommandText = "UPDATE personeltbl SET adres=\'" + S5 + "\' where pertc=\'" + S1 + "\'";

            co.ExecuteNonQuery();

        }

        if (S6 != "")

        {

            co.CommandText = "UPDATE personeltbl SET dogtar=\'" + S6 + "\' where pertc=\'" + S1 + "\'";

            co.ExecuteNonQuery();

        }

        if (S7 != "")

        {

            co.CommandText = "UPDATE personeltbl SET boy=\'" + S7 + "\' where pertc=\'" + S1 + "\'";

            co.ExecuteNonQuery();

        }

        if (S8 != "")

        {

            co.CommandText = "UPDATE personeltbl SET maas=\'" + S8 + "\' where pertc=\'" + S1 + "\'";

            co.ExecuteNonQuery();

        }

        TextBox1.Text = "";

             TextBox2.Text = "";

             TextBox3.Text = "";

             TextBox4.Text = "";

              TextBox5.Text = "";

              TextBox6.Text = "";

              TextBox7.Text = "";

              TextBox8.Text = "";

              co.CommandText = "Select * from personeltbl";

              SqlDataAdapter ad = new SqlDataAdapter();

        ad.SelectCommand = co;

        DataSet ds = new DataSet();

        ad.Fill(ds, "personeltbl");

        ListBox1.Items.Clear();

        foreach (DataTable table in ds.Tables)

                  foreach (DataRow kyt in table.Rows)

                ListBox1.Items.Add(kyt["pertc"] + " "

                    + kyt["ad"] + " " + kyt["soyad"] + " " + kyt["tel"] + " " + kyt["adres"] + " " + kyt["dogtar"] + " " + kyt["boy"] + "    " + kyt["maas"]);

             bag.Close();

    }

 

 

Bu web sitesi ücretsiz olarak Bedava-Sitem.com ile oluşturulmuştur. Siz de kendi web sitenizi kurmak ister misiniz?
Ücretsiz kaydol