文明从自身出发黑板报:在VC中,如何调用Date Time Picker控件

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 13:09:16
想通过点击Date Time Picker上的时间来查询出数据库中时间相符合的记录并显示在List Box.数据库中时间设置为日期/时间类型.
如有VC高手,希望能够互相帮助.请与我QQ联系59755288
代码如下:
void CMyTestDlg::Onchaxun()
{

if(m_date == "" )
{
AfxMessageBox("日期信息不能为空!");
return;
}

CString strDate;
UpdateData(true);
strDate.Format("SELECT * FROM testtable where 日期 = %s",this->m_date);//m_date是EDIT编辑框,定义为字符型,通过它把数据添加到数据库中
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
m_pRecordset->Open(LPCSTR(strDate),
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}

catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}

OnDisp();//刷新数据

}
这样查询是正确的,但我更想通过Date Time Picker来查询

在控件箱中把需要DLL控件包含进来。当然这个控件是要在你的计算机上注册过的才看到的。
发布的时候也要把这个控件打包进来,才能在其它计算机上正常运行。