Home > DeveloperSection > Blogs > See The Whole Data in DataGridView With Selecting A Value From ComboBox in ADO.NET

See The Whole Data in DataGridView With Selecting A Value From ComboBox in ADO.NET


ADO.Net ADO.Net 
Ratings:
5 Comment(s)
 3253  View(s)
Rate this:

See The Whole Data in DataGridView With Selecting A Value From ComboBox:

*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];

        }


See The Whole Data in DataGridView With Selecting A Value From ComboBox in ADO.NET

By Awadhendra Tiwari on   4 years ago

Hi Arijit Bhadra,

If you can explain your code then it is much better for readers.

Please do not show your contact information on Blogs, Articles and Forum.

Thanks.


See The Whole Data in DataGridView With Selecting A Value From ComboBox in ADO.NET

By Arijit Bhadra on   4 years ago
I will try definitely next time..

See The Whole Data in DataGridView With Selecting A Value From ComboBox in ADO.NET

By Uttam Misra on   4 years ago
Keep writing Arijit!

See The Whole Data in DataGridView With Selecting A Value From ComboBox in ADO.NET

By John Smith on   4 years ago
awadhendra is right....try to explain your code..

See The Whole Data in DataGridView With Selecting A Value From ComboBox in ADO.NET

By Arijit Bhadra on   4 years ago
Thanks Uttam..

Don't want to miss updates? Please click the below button!

Follow MindStick