troubleshooting Question

Retrieve combo box selection

Avatar of MichelleLacy
MichelleLacy asked on
.NET Programming
13 Comments1 Solution937 ViewsLast Modified:
I have two forms.  The first form as a combo box with a list of values.  When the user selects one of the items in the combo box, I want to send the results to the second form which contains a sql statement.  The sql statement uses the selectedText from the combox box in its WHERE statement.  I am having problems retrieving the selected text.  see code snippet.  please help....


public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        public static object seqType;
 
        private void cmboID_SelectedIndexChanged(object sender, EventArgs e)
        {
            seqType = cmboID.SelectedText.ToString();
        }  
    }
 
-------
 
public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }
 
....connection string inforamtion....
 
string sql = "SELECT column1, columns2 FROM table1 WHERE column1 = '" + Form2.seqType + "'";
....etc
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 13 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros