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!

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();
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.