944,119 Members | Top Members by Rank

Ad:
  • C# Code Snippet
  • Views: 10544
  • C# RSS
0

Dislay Data on datagrid

by on Apr 11th, 2008
Just post simple code. Give a feedback if it helps u
C# Code Snippet (Toggle Plain Text)
  1. using System;
  2. using System.Collection.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Data.SqlClient;
  9.  
  10. namespace WindowsApplication1
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18.  
  19. private void cmdtam_Klik(object sender, EventArgs e)
  20. {
  21. string cstr;
  22. cstr = "data source=jery;initial catalog=latihan;uid=sa;pwd=sri";
  23. SqlConnection con1 = new SqlConnection(cstr);
  24. con1.Open();
  25. SqlCommand com1 = new SqlCommand();
  26. com1.Connection = con1;
  27. com1.CommandType = CommandType.Text;
  28. com1.CommandText = "select * from customer"
  29. DataSet ds1 = new DataSet();
  30. SqlDataAdapter adp1 = new SqlDataAdapter(com1);
  31. adp1.Fill(ds1,"customer");
  32. grd1.DataMember = "customer";
  33. con1.Close();
  34. }
  35. }
  36. }
Comments on this Code Snippet
May 12th, 2008
0

Re: Dislay Data on datagrid

Nice snippet
Nearly a Posting Virtuoso
majestic0110 is offline Offline
1,306 posts
since Oct 2007
Jun 3rd, 2008
0

Re: Dislay Data on datagrid

thx majestic0110
Posting Sensei
Jx_Man is offline Offline
3,145 posts
since Nov 2007
Jul 14th, 2008
0

Re: Dislay Data on datagrid

Pl Help me for query related to update date in SQL Server2005
in C#.NET
Newbie Poster
kalekau is offline Offline
1 posts
since Jul 2008
Aug 18th, 2008
0

Re: Dislay Data on datagrid

hey...buddie,
did u help me ,i want to connect remote database(mysql) with c#.......
and update database using datagrid in c#
Newbie Poster
oscprofessional is offline Offline
3 posts
since Aug 2008
Message:
Previous Thread in C# Forum Timeline: Thread execution doubt
Next Thread in C# Forum Timeline: Adding custom rows at runtime from database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC