using (Connection = new SqlConnection(connectionstring))
{
SqlCommand voegtoe = new SqlCommand("INSERT INTO Speler(Naam, Rugnummer, Leeftijd) VALUES(@Naam, @Rugnummer, @Leeftijd)");
voegtoe.CommandType = CommandType.Text;
voegtoe.Connection = Connection;
voegtoe.Parameters.AddWithValue("@Naam", textBox1.Text);
voegtoe.Parameters.AddWithValue("@Rugnummer", textBox2.Text);
voegtoe.Parameters.AddWithValue("@Leeftijd", textBox3.Text);
Connection.Open();
voegtoe.ExecuteNonQuery();
}
If I open my Database there's nothing added to it. I think it should add the text what the user puts in the textboxes.
The connection string is:
Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Speler.mdf;Integrated Security=True