Witam kolegów i koleżanki na forum!
Mam pewien problem z pisanym przeze mnie programem.
Chcę poprzez dataSet dodawać, usuwać i aktualizować dane w bazie danych.
Dodawanie mi działa, gorzej z kasowaniem i aktualizacją, nie mam pojęcia co robię źle...
//DODAWANIE
private void button2_grupy_Click(object sender, EventArgs e)
{
DataTable dt = ds.Tables["Grupy"];
SqlCommandBuilder sb = new SqlCommandBuilder(da);
DataRow drow = dt.NewRow();
drow["grupa"] = textBox1_grupy.Text;
dt.Rows.Add(drow);
int updates = da.Update(ds, "Grupy");
MessageBox.Show("Dodano grupę: " + textBox1_grupy.Text);
textBox1_grupy.Clear();
}
//KASOWANIE
private void button4_grupy_Click(object sender, EventArgs e)
{
DataTable dt = ds.Tables["Grupy"];
SqlCommandBuilder sb = new SqlCommandBuilder(da);
int selected = listBox1_grupy.SelectedIndex;
dt.Rows[selected].Delete();
int updates = da.Update(ds, "Grupy");
MessageBox.Show("Skasowano grupę: " + textBox3_grupy.Text);
}
//EDYCJA
private void button3_grupy_Click(object sender, EventArgs e)
{
DataTable dt = ds.Tables["Grupy"];
SqlCommandBuilder sb = new SqlCommandBuilder(da);
dt.Rows[textBox2_grupy.Text]["grupa"] = textBox2_grupy.Text;
int updates = da.Update(ds, "Grupy");
MessageBox.Show("Zmieniono grupę: " + textBox2_grupy.Text);
}
Powiązałem listBoxa z textBoxami. Chciałbym, żeby kasował się ten wiersz, który jest zaznaczony, albo który się wyświetla w textBoxie, a edycja wiersza ten który jest w textBoxie