title: Is there a better way to insert values from arrays into SQL Server 2008?
body: <p>I am trying to store rows in a SQL Server 2008 table for a junkyard about documentation in all vehicles; I will run this program once a month that I receive a list with information for all vehicles. I know I can write a text file and do a "bulk insert" from a file. </p>
  
  <p>However, I just wondered if there is a way to insert information stored in string arrays directly into SQL Server.</p>
  
  <p>Right now I am doing a for loop and running 500 query commands to insert them, and for 500 records it only takes about 4 seconds the whole process.</p>
  
  <p>I would like to know <strong>if there is a better way</strong> to insert the information from arrays directly without using a for-loop 500 times?</p>
  
  <p>The code below works perfectly fine for me, however I would not like to use that kind of spaghetti code if there exists a better way to do it. Thanks in advance!</p>
  
  <pre><code>for (int i = 0; i &lt; 500; i++)
  {
      con.Open();
      SqlCommand myCommand = new SqlCommand("INSERT INTO [TESTCATALOG].[dbo].[TITLES] VALUES ('" + TitleNum[i] + "','" + VIN[i] + "','" + DateIssued[i] + "')", con);
      myCommand.ExecuteReader();
      con.Close();
  }
  </code></pre>