实习生id是一个字母数字值。
问题是运行程序后,搜索代码只对数字有效。不是字母数字的。我该如何解决这个问题。
private void button1_Click(object sender, EventArgs e)
{
if (txtsearch.Text != "")
{
MessageBox.Show("Please type intern number");
}
else
{
try
{
con.Open();
string SelectQuery2 = "SELECT * FROM interndetails WHERE internnumber =" + Convert.ToString(txtsearch.Text);
cmd4 = new MySqlCommand(SelectQuery2, con);
mdr2 = cmd4.ExecuteReader();
if (mdr2.Read())
{
textBox11.Text = mdr2.GetString("name");
textBox9.Text = mdr2.GetString("idnumber");
textBox6.Text = mdr2.GetString("status");
textBox12.Text = mdr2.GetString("statusdate");
textBox13.Text = mdr2.GetString("intakedate");
textBox14.Text = mdr2.GetString("fplacementdate");
textBox10.Text = mdr2.GetString("secbrdpt");
textBox15.Text = mdr2.GetString("periodcomplertion");
mdr2.Close();
con.Close();
}
else
{
MessageBox.Show("No Interns were found!");
txtsearch.Clear();
txtsearch.Focus();
}
con.Close();
}
catch (MySqlException x)
{
MessageBox.Show(x.Message);
con.Close();
}
}
}
}
2条答案
按热度按时间fsi0uk1n1#
可能对你有帮助吗
选择*from interndetails where concat(internnumber,'')='“+convert.tostring(txtsearch.text)+'”
laximzn52#
这样的方法应该有用: