I am trying to insert a value of type unsigned __int64 in MS Sql Server using OLE DB with C++ for a column which has sql_variant data type column. Although for all other data type I am able to do so.
Code snippet:
HRESULT hrinit = CoInitialize(NULL);
Cvar_table table;
HRESULT hro = table.OpenAll();
table.m_ValueId = 1;
table.m_dwValueIdStatus = DBSTATUS_S_OK;
unsigned __int64 ui = 1234567;
VARIANT vt;// <- This is not OK! I can not insert it
vt.vt = VT_UI8;
vt.ullVal = ui;
unsigned int ui4 = 1234567;
VARIANT vt4; //<- This is OK! I can insert this.
vt4.vt = VT_UI4;
vt4.ullVal = ui4;
table.m_Value = vt;
table.m_dwValueStatus = DBSTATUS_S_OK;
HRESULT hr = table.Insert();
if (FAILED(hr))
{
_tprintf(_T("Insert failed: 0x%X\n"), hr);
}
table.CloseAll();
CoUninitialize();
return 0;
I wonder if sql_variant supports VT_UI8? Thanks in advance.