Reply to thread

I am trying to get results from a sql server query:


   using (SqlConnection myConnection = new SqlConnection(ConnStr))

            {

                string oString = "Select Psw from Employees where Email = @E-Mail";

                SqlCommand oCmd = new SqlCommand(oString, myConnection);

                oCmd.Parameters.AddWithValue("@E-Mail", Email.Text);

                myConnection.Open();

                using (SqlDataReader oReader = oCmd.ExecuteReader())

                {

                    while (oReader.Read())

                    {

                       

                    }


                    myConnection.Close();

                }

            }



the thing is, "Email" is PK, so I know I will get only one result - one column and one row - a single value


Is this possible to get this single value strait into a string, without using  SqlDataReader? Because I know for sure I will get only one value so there is no need.


Continue reading...


Back
Top