Re[4]: Можно ли прочитать BLOB из oracle через OLE DB?
От: andrei_akm  
Дата: 22.12.08 16:03
Оценка:
Здравствуйте, LuciferArh, Вы писали:

LA>Здравствуйте, andrei_akm, Вы писали:


_>>Но я ведь установил на машину Oracle сервер (следовательно, и клиент), значит, и оракловый OLE DB. Я по аутпуту смотрел, грузятся оракловые dllи : D:\oracle\ora92\bin\OraOLEDB.dll и т.п.


LA>Это ни о чем не говорит. Строку подключения — в студию. Оракловые DLL будут грузиться в любом случае. Весь фокус в том, как их провайдер обработает.


Эээ...
Ну в общем подключаюсь тоже стандартно:

HRESULT hr = S_OK;
IRowsetChange* pIRowsetChange = NULL;

IDBProperties* pIDBProperties = NULL;
const ULONG cPropSets = 1;
const ULONG cProperties = 3;
DBPROPSET rgPropSets[cPropSets];
DBPROP rgProperties[cProperties];
const ULONG cLOGProperties = 3;
DBPROP rgLOGProperties[cLOGProperties];
const ULONG cCMPropSets = 1;
const ULONG cCMProperties = 1;
IDBCreateCommand* pCMIDBCreateCommand = NULL;
ICommandProperties* pCMICommandProperties = NULL;
DBPROPSET rgCMPropSets[cCMPropSets];
DBPROP rgCMProperties[cCMProperties];

for(ULONG i = 0; i < cLOGProperties; i++) VariantInit(&rgLOGProperties[i].vValue);

rgLOGProperties[0].dwPropertyID = DBPROP_INIT_DATASOURCE;
rgLOGProperties[0].vValue.vt = VT_BSTR;
rgLOGProperties[0].vValue.bstrVal = SysAllocString(database);
rgLOGProperties[0].dwOptions = DBPROPOPTIONS_REQUIRED;
rgLOGProperties[0].colid = DB_NULLID;

rgLOGProperties[1].dwPropertyID = DBPROP_AUTH_USERID;
rgLOGProperties[1].vValue.vt = VT_BSTR;
rgLOGProperties[1].vValue.bstrVal= SysAllocString(user);
rgLOGProperties[1].dwOptions = DBPROPOPTIONS_REQUIRED;
rgLOGProperties[1].colid = DB_NULLID;

rgLOGProperties[2].dwPropertyID = DBPROP_AUTH_PASSWORD;
rgLOGProperties[2].vValue.vt = VT_BSTR;
rgLOGProperties[2].vValue.bstrVal= SysAllocString(password);
rgLOGProperties[2].dwOptions = DBPROPOPTIONS_REQUIRED;
rgLOGProperties[2].colid = DB_NULLID;

rgPropSets[0].cProperties = cLOGProperties;
rgPropSets[0].rgProperties = rgLOGProperties;

hr = CoCreateInstance(CLSID_OraOLEDB, NULL, CLSCTX_INPROC_SERVER, IID_IDBInitialize, (void**)&m_pIDBInitialize);
hr = m_pIDBInitialize->QueryInterface(IID_IDBProperties, (void **)&pIDBProperties);
hr = pIDBProperties->SetProperties(cPropSets, rgPropSets);
hr = m_pIDBInitialize->Initialize();
hr = m_pIDBInitialize->QueryInterface(IID_IDBCreateSession, (void **)&m_pIDBCreateSession);
hr = m_pIDBCreateSession->CreateSession(NULL, IID_IDBCreateCommand, (IUnknown**)&pCMIDBCreateCommand);
hr = pCMIDBCreateCommand->CreateCommand(NULL, IID_ICommandText, (IUnknown**)&m_pICommandText);

rgCMPropSets[0].guidPropertySet = DBPROPSET_ROWSET;
rgCMPropSets[0].cProperties = cCMProperties;
rgCMPropSets[0].rgProperties = rgCMProperties;

rgCMPropSets[0].rgProperties[0].dwPropertyID = DBPROP_UPDATABILITY;
rgCMPropSets[0].rgProperties[0].dwOptions = DBPROPOPTIONS_REQUIRED;
rgCMPropSets[0].rgProperties[0].dwStatus = DBPROPSTATUS_OK;
rgCMPropSets[0].rgProperties[0].colid = DB_NULLID;
rgCMPropSets[0].rgProperties[0].vValue.vt = VT_I4;
V_I4(&rgCMPropSets[0].rgProperties[0].vValue) = DBPROPVAL_UP_CHANGE;

hr = m_pICommandText->QueryInterface(IID_ICommandProperties, (void **)&pCMICommandProperties);
hr = pCMICommandProperties->SetProperties(cCMPropSets, rgCMPropSets);

SAFE_RELEASE(pIDBProperties);
SAFE_RELEASE(pCMIDBCreateCommand);

 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.