title: How to pass c# datagridview selected cell values to SQL query
body: <p>I have a datagridview on C# form which has large number of rows. And selection option with check boxes. </p>
  
  <p>If I select 10 rows using check box selection I need to pass a column select row value to a SQL query to filter the records from another table.</p>
  
  <p>Below is my coding but its not working i don't how to solve this problem.</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
       SqlConnection conn1 = new SqlConnection(@"Data Source=.\sqlexpress;Initial Catalog=acc;Integrated Security=True");
       SqlCommand cmd1 = new SqlCommand(@"select db.date,db.type,db.refno,db.itmcod,db.qty,db.cuscod, db.cstcod,cus.cusnam INTO ##wec from fstktxn as db INNER JOIN fcustomer as cus on db.cuscod = cus.cuscod where itmcod = "dataGridView1.Rows[j].Cells["title"].Value", ", conn1);
  
       conn1.Open();
       cmd1.ExecuteNonQuery();
  
       SqlBulkCopy bulkCopy = new SqlBulkCopy(conn1);
       bulkCopy.DestinationTableName = "##tmp1";
  
       conn1.Close();
  }
  </code></pre>
  
  <p>Is there any solution to filter the data using gridview selection?</p>