0

I have a DataGridView in my first form and I made a second form to create a Database entry with following code:

    clsMSSQL.clsMSSQL ticket = new clsMSSQL.clsMSSQL(5);
    string query = "INSERT INTO ticket.support (Betreff, Problembeschreibung, Kategorie, Ersteller, Bearbeiter, E-Mail, Abteilung) " +
       "Values('" + textBox1.Text + "', '" + textBox2.Text + "', '" + comboBox1.Text + "', '" + textBox4.Text + "', '" + textBox5.Text + "', '" + textBox8.Text + "', '" + comboBox3.Text + "')";
    ticket.Query(query);
    ticket.Close();
    myDGW.Refresh();
    this.Close();

Now I made a third form which should be a able to get the selected row from the first form and change the values with the Textboxes.

I tried this:

    clsMSSQL.clsMSSQL ticket = new clsMSSQL.clsMSSQL(5);
    string query = "UPDATE ticket.support SET = (Betreff, Problembeschreibung, Kategorie, Ersteller, Bearbeiter, E-Mail, Abteilung) " +
       "Values('" + textBox1.Text + "', '" + textBox2.Text + "', '" + comboBox1.Text + "', '" + textBox4.Text + "', '" + textBox5.Text + "', '" + textBox8.Text + "', '" + comboBox3.Text + "') WHERE id='" + dataGridView1.Rows[i].Cells[11].Value.ToString() + "'";
    ticket.Query(query);
    ticket.Close();
    myDGW.Refresh();
    this.Close();

But it doesnt work.

Burak
  • 235
  • 1
  • 2
  • 12
  • Please show how you access controls from your forms. When you say "it doesn't work", you mean the textboxes values are not captured, or are you not able to access them at all? – Gabriel Marius Popescu Apr 29 '21 at 09:56
  • well i want to select the row from the DataGridView in Form1 and edit them on my Form2. But my Form2 doesn*t know which row is selected because Form1 and Form2 has no connection at all. – Burak Apr 29 '21 at 10:02
  • Does this answer your question? [Communicate between two windows forms in C#](https://stackoverflow.com/questions/1665533/communicate-between-two-windows-forms-in-c-sharp) – JohnG Apr 29 '21 at 16:02

0 Answers0