当前位置: 代码迷 >> C# >> 技术-密码*显示
  详细解决方案

技术-密码*显示

热度:480   发布时间:2016-05-05 04:09:32.0
技术求助-密码*显示

if (comboBox5.Text == "用户信息")
            {
                SqlConnection conn = new SqlConnection("server=.;database=小区物业;uid=sky;pwd=");
                conn.Open();
                SqlDataAdapter sty = new SqlDataAdapter("select * from YHXX where 用户名 like '%" + textBox28.Text + "%' or  真实姓名 like '%" + textBox28.Text + "%' or  联系电话 like '%" + textBox28.Text + "%' or  居住地址 like '%" + textBox28.Text + "%' or  居住人数 like '%" + textBox28.Text + "%' or  车位地址 like '%" + textBox28.Text + "%' or  面积 like '%" + textBox28.Text + "%' or 居住类型 like '%" + textBox28.Text + "%' or  房屋类型  like '%" + textBox28.Text + "%'", conn);
                DataSet ds = new DataSet();
                sty.Fill(ds);
                dataGridView1.DataSource = ds.Tables[0];
                conn.Close();
            }
怎么把密码那部分以*显示或者不显示?

------解决思路----------------------
用户管理一般不显示密码。一定要显示的话,可以在DataGridView 的事件 CellFormatting 中处理,事件函数的参数DataGridViewCellFormattingEventArgs e 的 e.ColumnIndex 如果是密码对应的列,就显示为星号,即 e.Value = "********";
------解决思路----------------------
引用:
select *改成逐个字段,密码直接用'*‘写死,现在密码长度都需要隐藏,所以连长度匹配都省了

顶,建议不显示密码
------解决思路----------------------
1、GridView把密码列隐藏
2、查询语句改成select具体的字段名,其中密码列(假设字段名称是pws)"*" as pws
3、处理查询结果,把结果集密码列替换成*
  相关解决方案