Hi,
I'm creating a program that reads data from a number of textfiles,
manipulates the data and then inserts it into a database. There are >200.000
rows and I use a SqlCommand object for each row . The SqlCommand object
calls a stored procedure that I have created.
There are approx. 10-15 different stored procedures that I use.
My problem is that the program is really slow, so what do I do wrong? Is
there a better way to do this?
Thanks,
Mats-Lennart
The code I use look something like this:
SqlConnection con = Utils.GetSqlConnection(); // Reuse the same
connection for all sql commands
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "procname";
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("P1", V1));
cmd.Parameters.Add(new SqlParameter("P2", V2));
cmd.Parameters.Add(new SqlParameter("P3", V3));
cmd.Connection = con;
cmd.ExecuteNonQuery();