0

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.

Amit
  • 228
  • 3
  • 8
  • Read this [sql_variant (Transact-SQL)](https://msdn.microsoft.com/en-us/library/ms173829.aspx). Especially the remarks. – shadow May 31 '16 at 06:25
  • I did not find anything there which suggests sql_variant does not support unsigned __int64. Can you please elaborate? One additional thing - I am able to store __int64, only problem is the unsigned __int64. – Amit May 31 '16 at 06:38
  • "ODBC does not fully support sql_variant". This put me in thoughts. – shadow May 31 '16 at 07:53

0 Answers0