Answers for "mysql C# select pk and all columns datareader"

C#
0

mysql C# select pk and all columns datareader

// Fill orderIDsList with OrderID's
        private void btnStart_Click(object sender, System.EventArgs e)
        {
            int iOrderID;

            // Create a command to select the Order IDs from the ORDERS table
            SqlCommand command = new SqlCommand
                ("SELECT OrderID from ORDERS", con);

            // Open the connection
            con.Open();

            // Get the data reader
            SqlDataReader reader = command.ExecuteReader();

            // Process each result
            while (reader.Read())
            {
                // Add each order ID in the result to the list
                // view containing the orders IDs. We have only
                // selected a single column in this code so we
                // can be pretty save in using reader.GetInit32(0)
                // there are no more columns in the data reader.
                iOrderID = reader.GetOrdinal("OrderID");
                orderIDsList.Items.Add (reader.GetInt32(iOrderID));
            }

            // Close the reader and the connection
            reader.Close();
            this.con.Close();
        }
Posted by: Guest on May-19-2020

C# Answers by Framework

Browse Popular Code Answers by Language