saving data into sql database from textboxes asp.net C#
<p>I have tried so many ways to save textbox text into an SQL database. I just want to save some text from textboxes into an SQL database. I am using 
Microsoft Visual Studio 2010 and C# programming language. 
Here is my current code:</p>

<pre class="lang-js prettyprint-override"><code>protected void BtnSave_Click(object sender, EventArgs e)
    {
        string Name = TxtFirstName.Text;
        string Address = TxtDOB.Text;
        string DOB = TxtDOB.Text;
        string Occupation = TxtOccupation.Text;
        string Home = TxtHome.Text;
        string Work = TxtWork.Text;
        string Mobile = TxtMobile.Text;
        string Email = TxtEmail.Text;
        string SportActivities = TxtSportActivities.Text;

        using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ClientsConnectionString"].ConnectionString)) ;
        {
            using (SqlCommand cmd = new SqlCommand("INSERT INTO [ClientDetails] ([Name], [Address], [DOB], [Occupation], [Home], [Work], [Mobile], [Email], [SportActivities]) VALUES ( @Name, @Address, @DOB, @Occupation, @Home, @Work, @Mobile, @Email, @SportActivities)")) ;
            {
                cmd.connection = con;
                con.Open();
                cmd.Parameters.AddWithValue("@Name", TxtFirstName.Text);
                cmd.Parameters.AddWithValue("@Address", TxtAddress.Text);
                cmd.Parameters.AddWithValue("@DOB", TxtDOB.Text);
                cmd.Parameters.AddWithValue("@Occupation", TxtOccupation.Text);
                cmd.Parameters.AddWithValue("@Home", TxtHome.Text);
                cmd.Parameters.AddWithValue("@Work", TxtWork.Text);
                cmd.Parameters.AddWithValue("@Mobile", TxtMobile.Text);
                cmd.Parameters.AddWithValue("@Email", TxtEmail.Text);
                cmd.Parameters.AddWithValue("@SportActivities", TxtSportActivities.Text);
                cmd.ExecuteNonQuery();
                con.close();
            }
        }
    }
</code></pre>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>protected void Button1_Click(object sender, EventArgs e)
        {
            string Name = TxtFirstName.Text;
            string Address = TxtDOB.Text;
            string DOB = TxtDOB.Text;
            string Occupation = TxtOccupation.Text;
            string Home = TxtHome.Text;
            string Work = TxtWork.Text;
            string Mobile = TxtMobile.Text;
            string Email = TxtEmail.Text;
            string SportActivities = TxtSportActivities.Text;

            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ClientDetailsConnectionString"].ConnectionString);

            SqlCommand cmd = new SqlCommand("INSERT INTO [ClientDetails] ([ID], [Name], [Address], [DOB], [Occupation], [Home], [Work], [Mobile], [Email], [SportActivities]) VALUES (@ID, @Name, @Address, @DOB, @Occupation, @Home, @Work, @Mobile, @Email, @SportActivities)");

            cmd.Connection = con;
            con.Open();
            cmd.Parameters.AddWithValue("@ID", TxtID.Text);
            cmd.Parameters.AddWithValue("@Name", TxtFirstName.Text);
            cmd.Parameters.AddWithValue("@Address", TxtAddress.Text);
            cmd.Parameters.AddWithValue("@DOB", TxtDOB.Text);
            cmd.Parameters.AddWithValue("@Occupation", TxtOccupation.Text);
            cmd.Parameters.AddWithValue("@Home", TxtHome.Text);
            cmd.Parameters.AddWithValue("@Work", TxtWork.Text);
            cmd.Parameters.AddWithValue("@Mobile", TxtMobile.Text);
            cmd.Parameters.AddWithValue("@Email", TxtEmail.Text);
            cmd.Parameters.AddWithValue("@SportActivities", TxtSportActivities.Text);
            cmd.ExecuteNonQuery();
            con.Close();
        }</code></pre>
</div>
</div>
</p>

<p>I have fixed my code. All i did was change 'CodeBehind' to CodeFile' in the aspx.cs file and fixed up some minor errors. Here is my working code:
All i did was remove the brackets as the code didnt recognise 'cmd' and added the 'ID' field as that was the primary key of my database so it had to be there. Everything works great. Thanks for your help. </p>