protected void Page_Load(object sender, EventArgs e) { using (con) { con.Open(); string str = ("select assign_g_id from assignvalue where no = 1"); MySqlCommand cmd = new MySqlCommand(str, con); MySqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); int temp = sdr.GetInt32(0); sdr.Close(); string username = Session["username"].ToString(); // str = "select prn from student where username = '******'"; //cmd = new MySqlCommand(str, con); // sdr = cmd.ExecuteReader(); //sdr.Read(); // int prn = sdr.GetInt32(0); // sdr.Close(); str = "update student set g_id='" + temp + "' where username = '******'"; cmd = new MySqlCommand(str, con); cmd.ExecuteNonQuery(); str = "select S_nm, PRN, g_id from student where g_id = " + temp + ""; MySqlDataAdapter sda = new MySqlDataAdapter(str, con); DataTable dtb1 = new DataTable(); sda.Fill(dtb1); GroupDetails.DataSource = dtb1; GroupDetails.DataBind(); } }
protected void Button1_Click(object sender, EventArgs e) { MySqlConnection con = new MySqlConnection(@"server = localhost; user id = root; pwd=shri@1234;persistsecurityinfo = True; database = auto"); using (con) { con.Open(); string str = ("select G_id from Guidegroup,Guide where Guide.Guide_Emp_id=GuideGroup.Guide_Emp_id and Guide.username='******'"); MySqlDataAdapter sda = new MySqlDataAdapter(str, con); DataTable dtb1 = new DataTable(); sda.Fill(dtb1); GroupDetails.DataSource = dtb1; GroupDetails.DataBind(); } }