Wrox Programmer Forums
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 30th, 2005, 01:59 AM
Registered User
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default filling of datagrid

i m trying to fill datadrid (dg1) from the data set (ds) of the table (emp) ,my code is like that

private void bt1_Click(object sender, System.EventArgs e)

        string select = "SELECT * FROM emp";
        SqlConnection cnn=new SqlConnection("Data source=localhost;Integrated Security=SSPI;" + "Initial Catalog=Rahul");

        SqlCommand cmd = new SqlCommand(select , cnn);
        SqlDataAdapter da = new SqlDataAdapter ( select ,cnn);
        DataSet ds = new DataSet();
        da.Fill(ds , "emp");




please solve my problem.

Old March 30th, 2005, 10:52 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts


dg1.DataSource = ds
dg1.DataMember = "emp"

Old June 29th, 2005, 06:24 AM
Friend of Wrox
Join Date: Sep 2004
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts

I think u r doing it on windows so SetDataBinding() is ok

Similar Threads
Thread Thread Starter Forum Replies Last Post
filling a datagrid with a crosstab? debbiecoates Pro VB Databases 0 April 15th, 2008 11:51 AM
filling the screen darkhalf CSS Cascading Style Sheets 0 September 26th, 2006 02:29 PM
Filling out DataSet from Datagrid MAKO C# 2 May 13th, 2006 08:15 AM
filling Dataset with datagrid variables frankv25 ASP.NET 1.0 and 1.1 Professional 1 August 30th, 2004 01:05 PM
filling of dataset abhimca_1 ADO.NET 2 August 5th, 2003 03:05 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.