大家帮忙看下是什么问题
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("请输入要查询的学员姓名", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox1.Focus();
}
else
{
FillListView();
}
}
private void FillListView()
{
string id;
string name;
string add;
string sex;
try
{
string sql = string.Format("select id,name,address,sex from student where name like'%{0}%'", textBox1.Text);
SqlCommand command = new SqlCommand(sql, DBHelper.connection);
SqlDataReader dataReader;
DBHelper.connection.Open();
dataReader = command.ExecuteReader();
listView1.Items.Clear();
if (!dataReader.HasRows)
{
MessageBox.Show("抱歉,没有你要查找的用户","消息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
while (dataReader.Read())
{
id = (string)dataReader["id"];
name = (string)dataReader["name"];
add = (string)dataReader["address"];
sex = (string)dataReader["sex"];
MessageBox.Show("cuowu");
ListViewItem lviStudent = new ListViewItem(id);
lviStudent.Tag = (int)dataReader["id"];
listView1.Items.Add(lviStudent);
lviStudent.SubItems.AddRange(new string[] { name, add, sex });
}
}
dataReader.Close();
}
catch
{
MessageBox.Show("查询数据库出错", "消息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
finally
{
DBHelper.connection.Close();
}
}
相关推荐
fpga设计中遇到的问题,大家看下
大家好,这个关于FPGA中NIOS的设计规则,大家看下,很好的
准备下英文自我介绍,准备下英文的对职位的认识和自己的能力,了解下面试的礼仪。下面给你一些英文面试经常问的问题,看下会好些:
准备下英文自我介绍,准备下英文的对职位的认识和自己的能力,了解下面试的礼仪。下面给你一些英文面试经常问的问题,看下会好些: Q: Can you sell yourself in two minutes? Go for it. (你能在两分钟内自我推荐吗?大胆试试吧!) A: With my qualifications and experience, I feel I am hardworking, responsible and diligent in any project I undertake. Your organization could benefit from my analytical and interpersonal skills.(依我的资格和经验,我觉得我对所从事的每一个项目都很努力、负责、勤勉。我的分析能力和与人相处的技巧,对贵单位必有价值。) Q:Give me a summary of your current job description. (对你目前的工作,能否做个概括的说明。) A:I have been working as a computer programmer for five years. To be specific, I do system analysis, trouble shooting and provide software support. (我干了五年的电脑程序员。具体地说,我做系统分析,解决问题以及软件供应方面的支持。) Q:Why did you leave your last job?(你为什么离职呢?) A: Well, I am hoping to get an offer of a better position. If opportunity knocks, I will take it.(我希望能获得一份更好的工作,如果机会来临,我会抓住。) A:I feel I have reached the "glass ceiling" in my current job. / I feel there is no opportunity for advancement. (我觉得目前的工作,已经达到顶峰,即没有升迁机会。) Q:How do you rate yourself as a professional?(你如何评估自己是位专业人员呢?) A: With my strong academic background, I am capable and competent. (
pre标签的css代码,防止代码pre中代码过长等问题
标签pre的css代码,防止代码pre中代码过长等问题,需要的朋友可以看下,有时候我们使用pre的时候对于代码过长的内容可以参考下面的写法: CSS Code复制内容到剪贴板 pre { whitewhite-space: pre-wrap; /* css-3 */ whitewhite-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ whitewhite-space: -pre-wrap; /* Opera 4-6 */ whitewhite-space: -o-p
Javascript字符串浏览器兼容问题分析
本文实例分析了Javascript字符串浏览器兼容问题。分享给大家供大家参考。具体分析如下: 先看下不兼容的写法,若我想获取某个字符串的第几位 代码如下:var str=’aavvvcc’; console.info(str[0]); 这种写法 在IE 7以下的浏览器都不兼容,以下提供浏览器全兼容的方式 代码如下:var str=’aavvvcc’; console.info(str.charAt(1)); 使用charAt() 就可以获取字符串中某个字符,并且全部兼容。 希望本文所述对大家的javascript程序设计有所帮助。
Win10系统突然无法识别U盘硬盘怎么办.doc
win10系统突然无法识别U盘\硬盘了,但是无法识别的U盘或硬盘在其他电脑上又可以使用所以估计是Win10问题!下面一起看下怎么解决这个问题。


