Ich habe Probleme damit herauszufinden, wie Daten in einer Datenbank mithilfe von Textfeldern und einer Schaltfläche aktualisiert und gelöscht werden.Löschen und Aktualisieren einer Datenbank C#
Mein Insert-Code ist:
private void button4_Click(object sender, EventArgs e)
{
try
{
string query = "insert into Prodaja values (@Prodajalec,@Prodajalna,@Kupec,@Vozilo,@DatumNakupa)";
using (connection = new SqlConnection(connectionString))
using (SqlCommand command = new SqlCommand(query, connection))
{
connection.Open();
command.Parameters.AddWithValue("@Prodajalec", textBoxProdajalec.Text);
command.Parameters.AddWithValue("@Prodajalna", textBoxProdajalna.Text);
command.Parameters.AddWithValue("@Kupec", textBoxKupec.Text);
command.Parameters.AddWithValue("@Vozilo", textBoxVozilo.Text);
command.Parameters.AddWithValue("@DatumNakupa", textBoxDatumNakupa.Text);
command.ExecuteNonQuery();
}
MessageBox.Show("Uspešno dodano");
this.prodajaTableAdapter.Fill(this.prodajaDataSet.Prodaja);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Ich habe versucht, ein paar verschiedene Methoden, aber sie nicht so recht klappen. Jede Hilfe wäre willkommen!
Welche Ausgabe/Fehlermeldung empfangen Sie? –