I am trying to add data to database. Its running with no error and when i check no data is there in table.
My code-
private void button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ProTestDB.mdf;Integrated Security=True;User Instance=True");
string name = textBox1.Text;
string sqlstr = ("INSERT INTO Users VALUES('" + textBox1.Text + "')");
SqlCommand cmd = new SqlCommand(sqlstr, conn);
cmd.Parameters.AddWithValue("Name", name);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
catch
{
MessageBox.Show("error");
}
}