void CMyADODlg::OnButtonAll()
{
// TODO: Add your control notification handler code here
ShowItem("select * from LinkInfo");
}
void CMyADODlg::OnButtonSearch()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if (m_cmbCondition.GetCurSel() == CB_ERR) //获取要查询的条件
return;
CString strCondition, strSQL;
m_cmbCondition.GetWindowText(strCondition);
//构造SQL语句
if(strCondition=="姓名")
strSQL.Format("select * from LinkInfo where Name Like '%s%s%s'", "%", m_strQuery, "%");
else if(strCondition=="电话")
strSQL.Format("select * from LinkInfo where Phone Like '%s%s%s'", "%", m_strQuery, "%");
else if(strCondition=="邮件")
strSQL.Format("select * from LinkInfo where Email Like '%s%s%s'", "%", m_strQuery, "%");
else if(strCondition=="地址")
strSQL.Format("select * from LinkInfo where address Like '%s%s%s'", "%", m_strQuery, "%");
else if(strCondition=="邮编")
strSQL.Format("select * from LinkInfo where postcode Like '%s%s%s'", "%", m_strQuery, "%");
ShowItem(strSQL); //在listControl中显示查询结果
UpdateData(FALSE);
}
ADO:查询
最新推荐文章于 2021-02-03 11:14:58 发布