0

Morning guyz,I need to create a conditional state ment using(if) to ask a statement to execute if content equals a string value and its not working.
This is what I mean

if(cboemployee=="All fieds")
{
 mysqlconnection sql = new mysqlconnection();
            sql.createconn();
            sql.command = sql.connection.CreateCommand();
                                               
               
                    sql.createconn();
                   sql.command = sql.connection.CreateCommand();
                   sql.command.CommandText ="  INSERT INTO Result(Name,Address,phn,Sex,Position) SELECT Name,Address,phn,Sex,position FROM Employee_data ";
                  MessageBox.Show("done");

                   sql.command.ExecuteNonQuery();
                   sql.connection.Close();
                   sql.connection.Dispose();
}

its working without if but when I but if it becomes static plz help now.

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
0

I wjust wanted to check if the picked option from the combo was "All fieds"

0

You cn do it this way:

if(cboemployee.SelectedItem.ToString().Equals("All fields"))
{
     //if it does, your code in here
}

or this way:

if(cboemployee.SelectedItem.ToString() == "All fields")
{
     //if it does, your code in here
}

Edited by Mitja Bonca: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.