DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   Code Snippet: Dislay Data on datagrid (http://www.daniweb.com/forums/thread217053.html)

Jx_Man Apr 11th, 2008 5:38 pm
Dislay Data on datagrid
 
Just post simple code. Give a feedback if it helps u :)

  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. }
majestic0110 May 12th, 2008 9:09 am
Nice snippet :)

Jx_Man Jun 3rd, 2008 2:11 am
thx majestic0110

kalekau Jul 14th, 2008 6:57 am
Pl Help me for query related to update date in SQL Server2005
in C#.NET

oscprofessional Aug 18th, 2008 4:19 am
hey...buddie,
did u help me ,i want to connect remote database(mysql) with c#.......
and update database using datagrid in c#


All times are GMT -4. The time now is 10:39 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC