1. You dont need to run
ExecuteNonQuery as you are populating SqlDataAdapter here.
2. Your button event why are you closing and reopening sql connection. instead use using block to create connection object it will take care of it.
if (!IsPostBack)
{
using(SqlConnection con = new SqlConnection(@"server=localhost; database=PS_User; trusted_connection=true;"))
{
con.open();
SqlCommand cmd = new SqlCommand(@"Select * from S1 WHERE PART =@1 AND PART IS NOT NULL Order by point", con);
cmd.Parameters.AddWithValue("@0", 0);
cmd.Parameters.AddWithValue("@1", 1);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
RadioButtonList1.DataTextField = "Name";
RadioButtonList1.DataValueField = "Point";
RadioButtonList1.DataSource = ds.Table[0];
RadioButtonList1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
using(SqlConnection con = new SqlConnection(@"server=localhost; database=PS_User; trusted_connection=true;"))
{
con.open();
string Name = RadioButtonList1.SelectedItem.Text.ToString();
string queryString = @"insert into t1 (Name,Point) values (@Name,@Point)";
SqlCommand cmd = new SqlCommand(queryString, con);
cmd.Parameters.AddWithValue("@Point", Label1.Text);
cmd.Parameters.AddWithValue("@Name", Name);
cmd.ExecuteNonQuery();
}
}