EXIT CODE

Featured by

INTRODUCTION TO C#

Microsoft’s .NET and C# opens a whole New World of possibilities. There are many people in the industry, which see a great future to the .NE...

22/01/2018

Searching from a textbox

try
            {

                string Query = "select * from ellie_nhcpms.user;";
                MySqlCommand cmd = new MySqlCommand(Query, connection);
                connection.Open();
                DataSet ds = new DataSet();
                string commandString = "select * from ellie_nhcpms.user where username= '" + UserName.Text + "'";
                MySqlCommand sqlCmd = new MySqlCommand(commandString, connection);
                MySqlDataReader read = sqlCmd.ExecuteReader();


                if (read.Read() == true)
                {
                    lblhos.Text = read["hospitalname"].ToString();
                    label11.Text = read["empid"].ToString();

                   


                }
                else
                {
                    lblhos.Text = "";
                    label11.Text = "";

                  
                }

                                connection.Close();
            }

            catch (Exception)
            {
                //MessageBox.Show(es.Message);
            }