protected void btn_submit_Click(object sender, EventArgs e) { if (chk_checkedbox.Checked == true) { SqlCommand sqlcom; int id = 1; sqlcon.Open(); sqlcom = new SqlCommand("Select columname from tablename", sqlcon); id = Convert.ToInt16 (sqlcom.ExecuteScalar()); sqlcon.Close(); } else { SqlCommand sqlcm; int id =0; sqlcon.Open(); sqlcm = new SqlCommand("Select columname from tablename", sqlcon); id = Convert.ToInt16 (sqlcm.ExecuteScalar()); sqlcon.Close(); } SqlCommand sqlcom; sqlcon.Open(); sqlcom = new SqlCommand("insert into tablename values('"+id+"')", sqlcon); sqlcom.ExecuteNonQuery(); sqlcom.Dispose(); sqlcon.Close(); }
Select columname from tablename
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)