C# – Store Procedure Güncelleme Örneği

C# – Store Procedure Güncelleme Örneği için tıklayınız.

frm1

sp5

 

private void personelguncelle()
{
SqlCommand komut = new SqlCommand();
komut.Connection = sqlConnection1;
komut.CommandType = CommandType.StoredProcedure;
komut.CommandText = “sp_guncelle”;
sqlConnection1.Open();
komut.Parameters.Add(“@no”, SqlDbType.Int);
komut.Parameters[“@no”].Value = textBox7.Text;
komut.Parameters.Add(“@ad”, SqlDbType.NVarChar, 30);
komut.Parameters[“@ad”].Value = textBox6.Text;
komut.Parameters.Add(“@soyad”, SqlDbType.NVarChar, 30);
komut.Parameters[“@soyad”].Value = textBox5.Text;
komut.Parameters.Add(“@iletisim”, SqlDbType.NVarChar, 50);
komut.Parameters[“@iletisim”].Value = textBox4.Text;
komut.Parameters.Add(“@firmano”, SqlDbType.Int);
komut.Parameters[“@firmano”].Value = comboBox2.SelectedIndex + 1;
komut.ExecuteNonQuery();
sqlConnection1.Close();

}

private void firmalistele()
{
sqlConnection1.Open();
string sorgu = “select firma_adi from firmalar”;
SqlDataAdapter adp = new SqlDataAdapter(sorgu,sqlConnection1);
DataSet ds = new DataSet();
adp.Fill(ds);
for (int i = 0; i <= ds.Tables[0].Rows.Count – 1; i++)
{
comboBox1.Items.Add(ds.Tables[0].Rows[i][0].ToString());
comboBox2.Items.Add(ds.Tables[0].Rows[i][0].ToString());
}
sqlConnection1.Close();

 

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
textBox7.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
textBox6.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
textBox5.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
textBox4.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();

}

private void button2_Click(object sender, EventArgs e)
{
personelguncelle();
KayitlariListele();
}
}

admin