ADO:查询

来源:互联网 发布:铃声编辑软件 编辑:程序博客网 时间:2024/04/25 17:39
void CMyADODlg::OnButtonAll() {// TODO: Add your control notification handler code hereShowItem("select * from LinkInfo");}void CMyADODlg::OnButtonSearch() {// TODO: Add your control notification handler code hereUpdateData(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);}

原创粉丝点击