Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

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
0
Moti Mashiah
Asked:
Moti Mashiah
  • 2
1 Solution
 
Moti MashiahAuthor Commented:
sorry I just figured out that I forgot to add text.

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now