try
{
CString strSQL;
strSQL.Format("Select InventoryNo,CheckingNo,Description,"
"[Department],Employee,DateAcquired,UnitPrice,Vendor,Status "
"From [家私基本信息] Where InventoryNo In "
"(Select InventoryNo From [资产维修信息] Where LimitDate<=GetDate())"
" And Status=2 And DepartmentID Like '%s' "
"Order By InventoryNo "
"Union "
"Select InventoryNo,CheckingNo,Description,"
"[Department],Employee,DateAcquired,UnitPrice,Vendor,Status "
"From [设备基本信息] Where InventoryNo In "
"(Select InventoryNo From [资产维修信息] Where LimitDate<=GetDate())"
" And Status=2 And DepartmentID Like '%s' "
"Order By InventoryNo",
gstrDepartmentID,gstrDepartmentID);
/////m_pSet为(CRecordset*)
if(m_pSet->IsOpen()) m_pSet->Close();m_pSet->Open(CRecordset::dynaset,strSQL,CRecordset::readOnly);
}
catch(...)
{
}以上语句在 Access 数据库里顺利执行,但在 SQL 里却出错,提示语法错误,未能准备语句,请各位指点!
{
CString strSQL;
strSQL.Format("Select InventoryNo,CheckingNo,Description,"
"[Department],Employee,DateAcquired,UnitPrice,Vendor,Status "
"From [家私基本信息] Where InventoryNo In "
"(Select InventoryNo From [资产维修信息] Where LimitDate<=GetDate())"
" And Status=2 And DepartmentID Like '%s' "
"Order By InventoryNo "
"Union "
"Select InventoryNo,CheckingNo,Description,"
"[Department],Employee,DateAcquired,UnitPrice,Vendor,Status "
"From [设备基本信息] Where InventoryNo In "
"(Select InventoryNo From [资产维修信息] Where LimitDate<=GetDate())"
" And Status=2 And DepartmentID Like '%s' "
"Order By InventoryNo",
gstrDepartmentID,gstrDepartmentID);
/////m_pSet为(CRecordset*)
if(m_pSet->IsOpen()) m_pSet->Close();m_pSet->Open(CRecordset::dynaset,strSQL,CRecordset::readOnly);
}
catch(...)
{
}以上语句在 Access 数据库里顺利执行,但在 SQL 里却出错,提示语法错误,未能准备语句,请各位指点!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货