0

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..

2
Contributors
3
Replies
36
Views
4 Years
Discussion Span
Last Post by JOSheaIV
0

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)

0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.