944,082 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 24939
  • C# RSS
Jan 11th, 2007
0

How to display a table on windows application in c#

Expand Post »
Hi everyone, I'm new here and I'm new to C# program.
I want to create a user name and passward verify windows application. I did some research, and finally get to connect to the database. Now I want to display the whole table which stores all the information. I know this does not help to verify the username and passward but help me to familiar with C# and database. Can anyone help me to point out the procedure or give me some hints? I will very very appreciate it.

Thanks.
Emma
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Emmaliu is offline Offline
2 posts
since Jan 2007
Jan 11th, 2007
0

Re: How to display a table on windows application in c#

Click to Expand / Collapse  Quote originally posted by Emmaliu ...
Hi everyone, I'm new here and I'm new to C# program.
I want to create a user name and passward verify windows application. I did some research, and finally get to connect to the database. Now I want to display the whole table which stores all the information. I know this does not help to verify the username and passward but help me to familiar with C# and database. Can anyone help me to point out the procedure or give me some hints? I will very very appreciate it.

Thanks.
Emma
When working with databases, ideally the best information you can get will be from a book which goes through it step by step.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Jan 11th, 2007
0

Re: How to display a table on windows application in c#

what you probably want to use is a gridview (or datagrid, if your are not on 2.0) and bind it to the database
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Jan 20th, 2007
0

Re: How to display a table on windows application in c#

use datagridview ,which will definately solve ur problem


string sqlSelect = "select * from usertest";
SqlCommand cmd = new SqlCommand(sqlSelect, conn);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adp.Fill(dt);
dgView.DataSource = dt;
dgView.DataBind();

here is the code which will help u to bind the database values to the grid(dgview),
Reputation Points: 10
Solved Threads: 0
Light Poster
amithasija is offline Offline
44 posts
since Nov 2006
Jan 21st, 2007
0

Re: How to display a table on windows application in c#

Thanks a lot.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Emmaliu is offline Offline
2 posts
since Jan 2007
Jan 27th, 2007
0

Re: How to display a table on windows application in c#

Click to Expand / Collapse  Quote originally posted by Emmaliu ...
Thanks a lot.
hey i hope this helps you out some

http://www.daniweb.com/techtalkforums/thread62112.html

its a HOWTO i wrote that covers how to query a database and return all of the information in a particular table.
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004
Nov 7th, 2009
-2
Re: How to display a table on windows application in c#
can i pass multiple quries to datagrid view, if yes then pls tell me how.
Reputation Points: 10
Solved Threads: 0
Light Poster
kool.net is offline Offline
28 posts
since Oct 2009
Nov 7th, 2009
0
Re: How to display a table on windows application in c#
Hey kool.net, don't resurrect old threads. Post your question in a new thread, where if needed you can refer freely to old threads if you want to.
Reputation Points: 2035
Solved Threads: 645
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008
Dec 30th, 2009
-1
Re: How to display a table on windows application in c#
I Think this is the complete code dude
C# Syntax (Toggle Plain Text)
  1. private void Form1_Load(object sender, EventArgs e)
  2. {
  3.  
  4. string connectionString = GetConnectionString();
  5. SqlConnection con = new SqlConnection(connectionString);
  6. string sqlSelect = "Select * from authors";
  7. SqlCommand cmd = new SqlCommand(sqlSelect,con);
  8. SqlDataAdapter adp = new SqlDataAdapter(cmd);
  9. DataTable dt = new DataTable();
  10. adp.Fill(dt);
  11. dataGridView1.DataSource = dt;
  12.  
  13. }
  14.  
  15. static private string GetConnectionString()
  16. {
  17. return "Data Source=localhost ; Initial Catalog = pubs;" + "Integrated Security=SSPI ";
  18. }
Last edited by Nick Evan; Dec 30th, 2009 at 7:38 am. Reason: Added code-tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kanchanraaj is offline Offline
1 posts
since Dec 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in C# Forum Timeline: a simple application of database...
Next Thread in C# Forum Timeline: need tutorial





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


Follow us on Twitter


© 2011 DaniWeb® LLC