我目前正在为Access 97进行SQL查询.给出以下表格(为演示目的而简化),每个表都位于不同的mdb文件中:
C:\ db\db1.mdb中的Table1:
PartyId (PK) Name
------------ --------
1 A
2 B
3 C
Run Code Online (Sandbox Code Playgroud)
C:\ db\db2.mdb中的表2:
PartyId (PK) Date (PK) Value
------------ --------- -----
1 6/30/2014 4
1 7/1/2014 8
2 5/3/2014 3
3 5/5/2014 5
3 5/3/2014 1
3 5/2/2014 2
Run Code Online (Sandbox Code Playgroud)
在这里,我想根据定义的日期查找每一方的最新价值.所以,比方说,我将7/5/2014标记为目标日期,然后我的查询应返回以下内容:
PartyId Name Date Value
------- ---- -------- -----
1 A 7/1/2014 8
2 B 5/3/2014 3
3 C 5/5/2014 5
Run Code Online (Sandbox Code Playgroud)
我在C:\ db\db1.mdb数据库中创建了以下查询:
SELECT T.TPartyId, Name, T.TDate, T.TValue
FROM Table1 INNER JOIN [
SELECT Table2.PartyId AS TPartyId, …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个 ATL COM 类,它具有以下方法:
STDMETHODIMP CTestClass::TestMethod(VARIANT VarIn, VARIANT_BOOL* bRes)
{
//VarIn is of type VT_INT
CComVariant var(VarIn);
var.ChangeType(VT_UI8); //doesn't work, HRESULT return value reports type mismatch
ULONGLONG ullVal = var.ullVal; //wrong value is assigned
*bRes = VARIANT_TRUE;
return S_OK;
}
Run Code Online (Sandbox Code Playgroud)
问题是CComVariant实例的类型在方法内部没有改变。例如,如果我将基于 int 的值 123 传递给上述方法,则不会VT_UI8执行to 类型转换。
但是,如果CComVariant在独立函数中使用该类,则通过该ChangeType()方法更改类型可以完美地工作:
void Function()
{
CComVariant var(123);
var.ChangeType(VT_UI8); //ok
ULONGLONG ullVal = var.ullVal; //correct value is assigned
}
Run Code Online (Sandbox Code Playgroud)
有什么我忽略了吗?谢谢。