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

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.

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

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

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

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 ";
        }

Edited 6 Years Ago by Nick Evan: Added code-tags

This article has been dead for over six months. Start a new discussion instead.