HERE I WANTED TO FILL MY BLANK RECORD WITH ITS VALID DATA

 private void button5_Click(object sender, EventArgs e)//modify
        {
            comm.Connection = conn;
            comm.CommandText = " UPDATE Table1 SET total='" + textBox6.Text + "',result='" + label7.Text + "' WHERE Fname ='" + textBox1.Text + "'";
            conn.Open();
            comm.ExecuteNonQuery();
            conn.Close();
            dataGridView1.Update();


        }

I WISH FOR A SIMPLE SINGLE LINE CODE..

You want a simple single line of code to do all that? Why not make a new function and move this all into that. Then call the function from the button click?

(A professor once told me, a program should not be written with the intent of using the least amount of lines of code possible, but should be written so that it can be the easiest to under read and understand)

in sql.. UPDATE is done with a single line of code.. y is nt that possible in c#

While I don't have experience with SQL in C#, I do have experience in C# using SQLite (same commands pretty much but a local file). When I use SQLite I have to use multiple lines of code as well.

Remember you have to connect to the database. So you have to connect, open the connection, write to it (ExecuteNonQuery), then close it. Much like you do when you writing to a file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.