inserting textbox value to sql server using c#
<p>I need to add a text box value to SQL Server database table. Below is my code:</p>

<pre><code>private void button1_Click(object sender, EventArgs e)
{
    string str = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\timetablesystem.mdf;Integrated Security=True;User Instance=True";
    SqlConnection con = new SqlConnection(str);
    string qry = "insert into SubjectMaster (SubjectName) values (@TxtSubjectName)";
    con.Open();
    SqlCommand cmd = new SqlCommand(qry, con);
    cmd.CommandType = CommandType.Text;
    cmd.Parameters.AddWithValue("@TxtSubjectName", TxtSubjectName.Text);
    cmd.ExecuteNonQuery();
    MessageBox.Show("Added Successfully!!");
    con.Close();
}
</code></pre>

<p>But, data should not add in table... please help me...
thanks for ur help...</p>
