检索数据表单数据库并选择特定的行 [英] retrieving data form database and selecting particular row

查看:44
本文介绍了检索数据表单数据库并选择特定的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数据库具有用户名,电子邮件,密码
用户在文本框中输入用户名,电子邮件将显示在Listview或文本框中,
因此我无法检索特定行no

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

推荐答案

Try:
Try:
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:我希望您不是将密码以明文形式存储在数据库中吗?这里有一个提示可以解释这一点:
密码存储:操作方法. [

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.[^]


这篇关于检索数据表单数据库并选择特定的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆