I have a big updated list of strings which must be uploaded with update of each row from 0 to last index by rewriting of exist records and adding of new rows to MySql database on remote server each time user calls function.
The adding of data string by string takes a lot of time even if not hangs by process:
foreach (string str in myList)
{
string Query = "insert into tab(a) values(@a);";
MySqlConnection conn = new MySqlConnection(connString);
MySqlCommand conn_ = new MySqlCommand(Query, conn);
conn.Open();
conn_.ExecuteNonQuery();
conn.Close();
}
My goal is to figure out, what should be most proper way to do this fast. Maybe I should create and update table locally and then somehow upload it to database.
I have a List<string> myList = new List<string>();
which contains about 5000 rows and I have table in database on remote server:
id | user | nickname
_____________________
0 | record | record
1 | ... | ...
My desired result is to update all records from 0 to highest index with adding of new records and removing of extra records in case if current upload contains less records then previous each time from 0 index, of course no maters if index will come with gap between removed rows.