private void button2_Click(object sender, EventArgs e) { { SqlConnection myConnection = new SqlConnection("****"); myConnection.Open(); try { SqlCommand myCommand = myConnection.CreateCommand(); myCommand.CommandText = "INSERT INTO Items (NameItem) " + "Values ('" + textBox2.Text + "')"; myCommand.ExecuteNonQuery(); MessageBox.Show("Item Added", "OK"); } catch (SqlException exp) { MessageBox.Show(exp.Message); } finally { myConnection.Close(); textBox2.Clear(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)