On the first look, youre code seems to be OK, but...
protected void btn1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=GAYATHRI\SQLEXPRESS;Initial Catalog=VOY_SERVICES1;Integrated Security=True"); con.Open();
foreach (TreeNode tnode in TreeView1.CheckedNodes)
{
if (tnode.Checked == true)
{
string strTreeValue;
strTreeValue = tnode.Value;
SqlCommand com = new SqlCommand("insert into treeview_select(subdisease_name) values(@name)", con);
com.Parameters.AddWithValue("@name", strTreeValue);
com.ExecuteNonQuery();
com.Dispose();
}
}
con.Close();
com = Nothing;
con = Nothing;
}
Have a nice day ;)