954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to display a table on windows application in c#

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

Emmaliu
Newbie Poster
2 posts since Jan 2007
Reputation Points: 10
Solved Threads: 0
 
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.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

what you probably want to use is a gridview (or datagrid, if your are not on 2.0) and bind it to the database

campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 

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),

amithasija
Light Poster
44 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

Thanks a lot.

Emmaliu
Newbie Poster
2 posts since Jan 2007
Reputation Points: 10
Solved Threads: 0
 
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.

Killer_Typo
Master Poster
781 posts since Apr 2004
Reputation Points: 152
Solved Threads: 39
 

can i pass multiple quries to datagrid view, if yes then pls tell me how.

kool.net
Light Poster
28 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

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.:)

ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 

I Think this is the complete code dude

private void Form1_Load(object sender, EventArgs e)
        {
            
            string connectionString = GetConnectionString();
            SqlConnection con = new SqlConnection(connectionString);
            string sqlSelect = "Select * from authors";
            SqlCommand cmd = new SqlCommand(sqlSelect,con);
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            adp.Fill(dt);
            dataGridView1.DataSource = dt;
           
        }  
         
        static private string GetConnectionString()
        {
            return "Data Source=localhost ; Initial Catalog = pubs;" + "Integrated Security=SSPI ";
        }
kanchanraaj
Newbie Poster
1 post since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You