Click here to Skip to main content
15,885,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Database is having username,email,pasword
user enters username in a textbox and his email is displayed in Listview or textbox,
so i'm nt able retrieve the paricular row no
Posted

1 solution

Try:
C#
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand com = new SqlCommand("SELECT username,email,pasword FROM myTable WHERE username=@UN", con))
        {
        com.Parameters.AddWithValue("@UN", username);
        using (SqlDataReader reader = com.ExecuteReader())
            {
            if (reader.Read())
                {
                ...
                }
            }
        }
    }
BTW: I hope you aren't storing passwords in the DB in clear text? There is a Tip here that explains this:
Password Storage: How to do it.[^]
 
Share this answer
 
Comments
dare2dash 8-Feb-12 3:28am    
i want to do it using dataset
OriginalGriff 8-Feb-12 3:45am    
Then use the same technique with a DataAdapter - they have a SelectCommand property with works the same way:
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.selectcommand.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900