protected void Unnamed_Click(object sender, EventArgs e)
{
//TextBox t = DetailsView1.FindControl("TextBox1") as TextBox;
string conStr = ConfigurationManager.ConnectionStrings["testdbConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(conStr))
{
if (ddlSelect.SelectedValue == "1")
{
abc(txt1.Text, con);
}
if (ddlSelect.SelectedValue == "2")
{
abc(txt1.Text, con);
abc(TextBox2.Text, con);
}
}
}
void abc(string value, SqlConnection con)
{
SqlCommand cmd = new SqlCommand();
cmd = new SqlCommand("INSERT INTO BookMaster(BookName) VALUES (@BookName)", con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@BookName", value);
con.Open();
cmd.ExecuteReader();
con.Close();
}
No comments:
Post a Comment