Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C# display checkbox

Posted on 2014-04-14
2
Medium Priority
?
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

704 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