【发布时间】:2011-10-12 18:49:40
【问题描述】:
我的计划是当我插入字母 M 时,单词开头的整个字母 M 将使用列表框显示,但我不能这样做。我使用了这段代码,但我找不到它为什么不起作用:
conn.Open();
OleDbCommand cmd2 = new OleDbCommand("SELECT fnID, Lastname, Firstname, Middlename FROM tbl_Fullname WHERE Firstname LIKE '%?'", conn);
cmd2.Parameters.Add("@Firstname", OleDbType.VarChar).Value = textBox3.Text;
try
{
OleDbDataReader dr = cmd2.ExecuteReader();
if (dr.Read())
{
textBox1.Text = dr[0].ToString(); //fnID
listBox1.Items.Add(dr[1].ToString()); //Lastname
textBox3.Text = dr[2].ToString(); //Firstname
textBox4.Text = dr[3].ToString(); //Middlename
}
else
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
//MessageBox.Show("No result");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
conn.Close();
【问题讨论】:
-
您能否重新表述您的计划声明(您的第一行),以便我们易于阅读(并且有些意义)?