.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Windows Application

Posted By: Jayakumar     Posted Date: March 01, 2010    Points:2   Category :Windows Application
hi


how to show my table(sqlserver) with my datagrid in windows application, programmatically ...


regards
jai

Responses
Author: Naresh             
Posted Date: March 01, 2010     Points: 5   

Hi JayaKumar,
Do u want to display you data from a specific table n data grid.

Thanks
Naresh
Author: Jayakumar             
Posted Date: March 01, 2010     Points: 5   

hi

s, from the specific table called "A".

Author: Syed Shakeer Hussain             
Posted Date: March 01, 2010     Points: 5   

Hi jaykumar

below code for displaying table data in datagrid

private void Form1_Load(object sender, System.EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM A",conn );
DataSet ds = new DataSet();
da.Fill(ds, "A");
dataGrid1.DataSource = ds.Tables["A"].DefaultView ;
}


Author: Naresh             
Posted Date: March 02, 2010     Points: 5   

hi JayaKumar,


Bind Data from Sql database to datagrid:

In page load :

SqlConnection con = new SqlConnection("Server=LocalHost;DataBase=Student;Uid=sa;Pwd=sa");
SqlCommand cmd1 = new SqlCommand("select * from A", con);
DataTable t = new DataTable();
SqlDataAdapter dr2 = new SqlDataAdapter(cmd1);
dr2.Fill(t);
this.DataGrid1.DataSource = t;
this.DataGrid1.DataBind();
con.close();

thanks

Thanks
Naresh


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend