Solved

C# display checkbox

Posted on 2014-04-14
2
238 Views
Last Modified: 2014-04-14
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
Comment
Question by:Moti Mashiah
  • 2
2 Comments
 
LVL 1

Accepted Solution

by:
Moti Mashiah earned 0 total points
ID: 40000105
sorry I just figured out that I forgot to add text.

tring Query = "select * from [order] where id='" + comboBox1.text + "' ;";
0
 
LVL 1

Author Closing Comment

by:Moti Mashiah
ID: 40000107
solved my issue
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question