Click here to Skip to main content
15,914,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys.

I have a datagridview that displays the 50 percent of the total number of the records in the database. Now, I need to update their section name in tblclass, tblstudentinfo. I do not know how. Can anyone help me?

Here is my code:

p_table1 = new DataTable();
              p_table1.Clear();
              string questa = "SELECT  TOP 50 Percent * from tblStudentInformation Where GradeLevel ='" + label2.Text + "' and Result >= 85  and SectionName IS NULL";
              SqlDataAdapter rad = new SqlDataAdapter(questa, conn);
              rad.Fill(p_table1);
              dataGridView2.DataSource = p_table1;
Posted
Comments
Sergey Alexandrovich Kryukov 19-Jan-15 3:44am    
Such questions are asked probably more often than weekly. Why not looking at existing questions and answers?
—SA
DarkDreamer08 19-Jan-15 3:54am    
i have tried looking for articles and I cannot find any that will help me to solve my problem. I am sorry if I am such an idiot in terms of that. I just wanted to learn. I just needed assistance and advise from others :(
Sergey Alexandrovich Kryukov 19-Jan-15 13:42pm    
Please don't say such bad words about yourself. We all have some hard time learning from time to time. Just be patient. I remember that there were many, many answers (I did not mean articles) to the questions very similar to yours.
—SA

1 solution

p_table1 = new DataTable();
p_table1.Clear();
string questa = "SELECT TOP 50 Percent * from tblStudentInformation Where GradeLevel ='" + label2.Text + "' and Result >= 85 and SectionName IS NULL";
SqlDataAdapter rad = new SqlDataAdapter(questa, conn);
rad.Fill(p_table1);
dataGridView2.DataSource = p_table1;

string data= "update tblStudentInformation set SectionName ='your update value' where Where GradeLevel ='" + label2.Text + "' and Result >= 85 and SectionName IS NULL";
rad = new SqlDataAdapter(data, conn);
rad.Fill(p_table1);
dataGridView2.DataSource = p_table1;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900