try
{
string connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Customers.mdf;Integrated Security=True;User Instance=True";
using (SqlConnection connection = new SqlConnection(connectionString))
using (SqlCommand command = connection.CreateCommand())
{
command.CommandText = "INSERT INTO TableName(ColumnName1, ColumnName2, ColumnName3) VALUES (@value1, @value2, @value3)";
command.Parameters.AddWithValue("@value1", ContactBox1.Text);
command.Parameters.AddWithValue("@value2", ContactBox2.Text);
command.Parameters.AddWithValue("@value3", ContactBox3.Text);
connection.Open();
command.ExecuteNonQuery();
}
}
catch (SqlException ex)
{
Console.WriteLine(ex.Message);
}