---
title: "See The Whole Data in DataGridView With Selecting A Value From ComboBox in ADO.NET"  
description: "*Write this code  on the Button*private void  button1_Click(object sender, EventArgs e)                SqlConnection con = new  SqlConnection();"  
author: "Arijit Bhadra"  
published: 2011-10-07  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/247/see-the-whole-data-in-datagridview-with-selecting-a-value-from-combobox-in-ado-dot-net  
category: "ado.net"  
tags: ["ado.net"]  
reading_time: 1 minute  

---

# See The Whole Data in DataGridView With Selecting A Value From ComboBox in ADO.NET

##### *Write this code on the Button*

```
private void
button1_Click(object sender, EventArgs e)        {            SqlConnection con = new
SqlConnection();            con.ConnectionString = "Data
Source=home-1117080bc2;Initial Catalog=Hotel_Booking;User
ID=sa;Password=sqlforarijit";            con.Open();            SqlCommand cmd = new
SqlCommand("select * from new_reservation where customer_id = @a",
con);            cmd.Parameters.Add("@a",
SqlDbType.VarChar, 50);           
cmd.Parameters["@a"].Value = comboBox1.Text;            SqlDataAdapter ada = new
SqlDataAdapter(cmd);            SqlCommandBuilder build = new
SqlCommandBuilder(ada);            DataSet ds = new DataSet();            ada.Fill(ds,
"new_reservation");            dataGridView1.DataSource =
ds.Tables[0];        }
```

---

Original Source: https://www.mindstick.com/blog/247/see-the-whole-data-in-datagridview-with-selecting-a-value-from-combobox-in-ado-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
