venus najad

venus najad

  • 993
  • 414
  • 30k

how to refill a specific row in Data Table in C# asp net

Aug 7 2023 5:49 PM

hello everyone. i have a data table, tblrating and i will refill a specific row in it. i have selected that row and hen insert the values, wihtout any result???!!! the codes are as follow:

sxtring q = string.Format("select * from tblrating where Nr='{0}'", rew_n[0]);
            command.CommandText = q;

            int amountOfUsers = Convert.ToInt32(command.ExecuteScalar());
            if (amountOfUsers >= 1) //the row exist
            {
                int rew = (j + rew_n[3] * (rew_n[1] - 1)) / rew_n[1];
                q = string.Format(@"INSERT INTO tblrating (Email,Title,Visitors,rating,review,Nr)VALUES
                ('" + adEmail.Text + "','" + s[1].ToString() + "','" + rew_n[1]++ + "','" + j + "','" + rew + "','" + rew_n[0] + "')");

                command.CommandText = q;
                command.ExecuteNonQuery();
            } 

i tried with: 

q = string.Format(@"INSERT INTO tblrating (Email,Title,Visitors,rating,review,Nr)VALUES
                ('" + adEmail.Text + "','" + s[1].ToString() + "','" + rew_n[1]++ + "','" + j + "','" + rew + "','" + rew_n[0] + "') where Nr='{0}'", rew_n[0]);

but got error: i appreciate any help... kind regards


Answers (3)