private void buttonLastest2_Click(object sender, EventArgs e) { viewPanel.Visible = true; InsertPanel.Visible = false; printPanel.Visible = false; indiInsert.Visible = false; indiView.Visible = true; indiPrint.Visible = false; updateStudent upst = new updateStudent(); upst.getvalues(); upst.setPosition(); SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SHATTER\source\repos\REPORTBYTE\repoBite.mdf;Integrated Security=True;Connect Timeout=30"); con.Open(); string query = "SELECT Index_No, Name, Position, Sub1, Sub2, Sub3, Sub4, Sub5, Sub6, Sub7, Sub8, Sub9, Sub10, Sub11, Sub12, Total_Marks, Average FROM Students"; SqlDataAdapter adaptor = new SqlDataAdapter(query, con); DataSet set = new DataSet(); adaptor.Fill(set, "Students"); dataGridView1.DataSource = set.Tables["Students"]; //SqlCommandBuilder builder = new SqlCommandBuilder(adaptor); adaptor.Update(set.Tables["Students"]); con.Close(); }
private void buttonLastest15_Click(object sender, EventArgs e) { updateStudent upst = new updateStudent(); upst.getvalues(); upst.setPosition(); SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SHATTER\source\repos\REPORTBYTE\repoBite.mdf;Integrated Security=True;Connect Timeout=30"); con.Open(); //get value from teacher name. pass value +1 to get marks int value = comboBox4.SelectedIndex + 1; string query = "SELECT Index_No, Name, Sub" + value + ",Position FROM Students"; SqlDataAdapter adaptor = new SqlDataAdapter(query, con); DataSet set = new DataSet(); try { adaptor.Fill(set, "Students"); dataGridView2.DataSource = set.Tables["Students"]; adaptor.Update(set.Tables["Students"]); con.Close(); }catch (Exception ex) { timer(Convert.ToString(ex)); } }