title: How Do I Insert Data I Pulled From A SQL Table I Assigned To A Dictionary<int, int>?(ASP.Net)
body: <p>I assigned two int values (<code>CampaignId</code> and <code>LinkId</code>) from one SQL Server table to a <code>Dictionary&lt;int,int&gt;</code> variable and now I am trying to insert it into another SQL Server table. What do I need to do to get each data value I assigned to the dictionary into the</p>
  <pre><code>command.parameters.Add(@UserAgent, ????) 
  </code></pre>
  <p>and</p>
  <pre><code>command.parameters.Add(@LinkId, ????)
  </code></pre>
  <p>My code</p>
  <pre><code>string queryString = &quot;SELECT CampaignId, LinkId FROM TrackClick WHERE UserAgent IS NOT NULL;&quot;;         
  
  var UserDetails = new Dictionary&lt;int, int&gt;();
  
  using (SqlConnection connection = new SqlConnection(con))
  {
      SqlCommand command = new SqlCommand(queryString, connection);
      connection.Open();
  
      using SqlDataReader reader = command.ExecuteReader();
  
      while (reader.Read())
      {
          UserDetails.Add(reader.GetInt32(0), reader.GetInt32(1));
      }
  }
   
  var insertString = @&quot;INSERT INTO dbo.User_Details (CampaignId, LinkId,)
                       VALUES (@CampaignId, @LinkId)&quot;;
  
  using var connection = new SqlConnection(con);
              //code to insert the insertString
  
  SqlCommand command = new SqlCommand(insertString, connection);
  command.Parameters.AddWithValue(&quot;@CampaignId&quot;,/* ????*/);
  command.Parameters.AddWithValue(&quot;@LinkId&quot;,/* ????*/);
  
  connection.Open();
  
  // insert bulk Records into DataBase.  
  command.ExecuteNonQuery();
  connection.Close();
  </code></pre>