Hi,

How best to put the array (100 or more length) in the database (MySQL)?

I do not want multiple access to the database because it is so loaded.

So my solution is as follows:

string insert = "INSERT INTO programs (name, id) VALUES ";

            for(int i = 0; i < name.Length; i++)
            {
                if (i != 0)
                {
                    insert = insert + ",(";
                }
                else
                {
                    insert = insert + "(";
                }

                insert = insert + "'" + name[i] + "','" + id[i] + "'";

                insert = insert + ")";
            }

            //INSERT INTO programs (name, id) VALUES ('Peter','32'),('Rikko','343') ....

But maybe is a faster version?

Thanks

>But maybe is a faster version?

Use parametrized query.

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.