0

How to retrieve data from the database with the field name employeeID in the table employee i try to use SELECT employeeID FROM employee but it does not work.

Can someone give me a meaningful code for retrieving my data?

I have login form with the login button. I want the username and password inputted my user save to my table name History after clicking the login button.

Please send me any reply.

Thank you!

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Momerath
0

What database are you using? If SQL Server, then something like:

public void ReadData(string connectionString) {
    string queryString = "SELECT employeeID FROM employee;";
    using (SqlConnection connection = new SqlConnection(connectionString)) {
        SqlCommand command = new SqlCommand(queryString, connection);
        connection.Open();
        SqlDataReader reader = command.ExecuteReader();
        try {
            while (reader.Read()) {
                Console.WriteLine("{0}", reader[0]);
            }
        } finally {
            reader.Close();
        }
    }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.