---
title: "How To Use Two Queries One Datagrid"  
description: "How To Use Two Queries One Datagrid"  
author: "Demir ACAR"  
published: 2014-09-03  
updated: 2014-09-03  
canonical: https://www.mindstick.com/forum/2242/how-to-use-two-queries-one-datagrid  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# How To Use Two Queries One Datagrid

I have 2 [server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) and 2 [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) , how to [query](https://www.mindstick.com/blog/202/sub-query-in-sqlserver) 2 [databases](https://www.mindstick.com/startup/34/airbyte-the-open-source-platform-simplifying-data-integration-for-warehouses-lakes-and-databases) that localated different place and [collect](https://www.mindstick.com/interview/34468/how-do-you-collect-and-clean-datasets) the [result](https://www.mindstick.com/blog/12011/advantages-of-getting-result-oriented-seo-from-an-agency) one datagrid .

```
for (int ii = 0; i < gridView1.RowCount; i++)                {                    SqlConnection conn = new SqlConnection(@"Data Source='" + tb6 + "';Initial Catalog='" + tb7 + "';user='" + tb8 + "';pwd='" + tb9 + "'");                    SqlConnection conn2 = new SqlConnection(@"Data Source='" + tb1 + "';Initial Catalog='" + tb2 + "';user='" + tb3 + "';pwd='" + tb4 + "'");                    SqlCommand cmd = new SqlCommand("SELECT ID AS REF ARACTIPI AS TIP,ARACADI AS ADI,MARKA AS MARKA FROM ARACBILGILER", conn);                    DataTable tablo = new DataTable();                    conn.Open();                    conn2.Open();                    SqlDataReader oku = cmd.ExecuteReader();                    tablo.Load(oku);                    SqlCommand cmd2 = new SqlCommand("SELECT DURUMU AS ARAC_DURUMU FROM ARACDB WHERE ID='" + gridView1.GetDataRow(i)["REF"] + "'", conn2);                    SqlDataReader oku2 = cmd2.ExecuteReader();                    tablo.Load(oku2);                    gridControl1.DataSource = tablo;conn.Close();conn2.Close();}}}
```


---

Original Source: https://www.mindstick.com/forum/2242/how-to-use-two-queries-one-datagrid

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
