Solved

C# display checkbox

Posted on 2014-04-14
2
232 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

706 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now