C# display checkbox

Hi guys ,

I have some issue when I check some item from my drop box and trying to display the closed status in the dropbox.

here is my code: I attached also the error screenshot

string conn = "Data Source=srv-db-02;Initial Catalog=rmsmasterdbtest;Persist Security Info=True;User ID=sa;Password=********";
            string Query = "select * from [order] where id='" + comboBox1 + "' ;";

            SqlConnection myConn = new SqlConnection(conn);
            SqlCommand cmd = new SqlCommand(Query, myConn);
            SqlDataReader reader;

            try
            {
                myConn.Open();
                reader = cmd.ExecuteReader();

                if(reader.Read())
                {
                    bool check = reader.GetBoolean(reader.GetOrdinal("closed"));
                    

                    checkBox1.Checked = check;
                    
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                myConn.Close();
            }

Open in new window

Capture.JPG
LVL 1
Moti Mashiah.NET DeveloperAsked:
Who is Participating?
 
Moti MashiahConnect With a Mentor .NET DeveloperAuthor Commented:
sorry I just figured out that I forgot to add text.

tring Query = "select * from [order] where id='" + comboBox1.text + "' ;";
0
 
Moti Mashiah.NET DeveloperAuthor Commented:
solved my issue
0
All Courses

From novice to tech pro — start learning today.