TEXT
71
A2
Guest on 13th June 2022 05:03:18 AM
private void brisanjeToolStripMenuItem_Click(object sender, EventArgs e)
{
string stringkonekcije = "Data Source=DELL-PC;Initial
Catalog=SkolskaBiblioteka;User ID=sa;Password=Tesla1980";
string upit = "delete from Autor where AutorID='"+txtSifra.Text+"';";
SqlConnection konekcija = new SqlConnection(stringkonekcije);
SqlCommand komanda = new SqlCommand(upit, konekcija);
try
{
konekcija.Open();
komanda.ExecuteNonQuery();
MessageBox.Show("Uspesno brisanje");
Ispis();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
konekcija.Close();
}
}
private void Form1_Load(object sender, EventArgs e)
{
Ispis();
}
private void Ispis()
{
string[] arr = new string[4];
ListViewItem itm;
string stringkonekcije = "Data Source=DELL-PC;Initial
Catalog=SkolskaBiblioteka;User ID=sa;Password=Tesla1980";
string upit = "select * from Autor;";
SqlConnection konekcija = new SqlConnection(stringkonekcije);
SqlCommand komanda = new SqlCommand(upit, konekcija);
SqlDataReader mojreader;
try
{
konekcija.Open();
mojreader = komanda.ExecuteReader();
listView1.Items.Clear();
while (mojreader.Read())
{
arr[0] = mojreader["AutorID"].ToString();
arr[1] = mojreader["Ime"].ToString();
arr[2] = mojreader["Prezime"].ToString();
arr[3] = mojreader["DatumRodjenja"].ToString();
itm = new ListViewItem(arr);
listView1.Items.Add(itm);
}
mojreader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
konekcija.Close();