INSERT Statement Doesn't Insert into SQL Server Database working with C# Winform
<p>I am trying to insert the costumer's information into a SQL Server database from a C# Winforms, although when I click on the Add button no error shows, the no data is being added into the database.</p>

<p>Here is the code for the Add function:</p>

<pre><code> private void acceptButton_Click(object sender, EventArgs e)
 {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);

        String query = "INSERT INTO Costumer(Name, Address, Phone, Note) VALUES(@name, @address, @phone, @note)";

        SqlCommand command = new SqlCommand(query, con);


        command.Parameters.AddWithValue("@name", nameTextBox.Text);
        command.Parameters.AddWithValue("@address", addressTextBox.Text);
        command.Parameters.AddWithValue("@phone", phoneTextBox.Text);
        command.Parameters.AddWithValue("@note", noteTextBox.Text);

        try
        {
            con.Open();
            command.ExecuteNonQuery();
            con.Close();
            this.Close();
        }
        catch (SqlException exception)
        {
            MessageBox.Show(exception.Message.ToString(), "Error Message");
        }
    }
</code></pre>

<p>Here is the design of the Costumer table</p>

<pre><code>CREATE TABLE [dbo].[Costumer] (
  [CostumerId] INT           IDENTITY (1, 1) NOT NULL,
  [Name]       VARCHAR (50)  NULL,
  [Address]    VARCHAR (50)  NULL,
  [Phone]      VARCHAR (16)  NULL,
  [Note]       VARCHAR (250) NULL,
  PRIMARY KEY CLUSTERED ([CostumerId] ASC)
);
</code></pre>

<p>Not sure where the issue is here.</p>

<p><strong>Edit:</strong> The connection string I used in the winform project.</p>

<p>Here is the connection string:</p>

<pre><code>&lt;add name="myConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;Connect Timeout=30;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient"/&gt;
</code></pre>

<p>I have used the same connection string for several SELECT queries and they worked fine.</p>