Click here to Skip to main content
15,891,976 members
Home / Discussions / COM
   

COM

 
GeneralProblem While Instantiating and calling API through COM Component Pin
Anuj Mishra2-Mar-05 18:04
Anuj Mishra2-Mar-05 18:04 
GeneralIE code download failure for dll and ActiveX control using INF and CAB file Pin
prog012-Mar-05 11:40
prog012-Mar-05 11:40 
GeneralBindIFilterFromStream Pin
cheesepirate2-Mar-05 7:02
cheesepirate2-Mar-05 7:02 
Generaldyanamically create listboxes in ATL Pin
gauravjain1-Mar-05 4:28
gauravjain1-Mar-05 4:28 
GeneralCommunication with one particular instance of an activex/com object Pin
awhit1-Mar-05 0:54
awhit1-Mar-05 0:54 
GeneralCOM and MSFlexGrid Pin
A. Karthick Arun28-Feb-05 20:34
A. Karthick Arun28-Feb-05 20:34 
GeneralCOM,OLE,AUTOMATION,ActiveX Pin
hjkjk28-Feb-05 20:16
hjkjk28-Feb-05 20:16 
GeneralCreating Schema Rowset ( OLE DB) in COM Pin
gauravjain28-Feb-05 5:47
gauravjain28-Feb-05 5:47 
hi!!
im trying to create a Schema rowset as i want to display the tables existing in the database.
but im geting a Windows Error Report as soon as i execute getrowset function. Im building a COM using ATL.
any help is welcome.

STDMETHODIMP Cfuctcont::pop()
{
// TODO: Add your implementation code here

DBPROP InitProperties[5], InitProperty[3];
DBPROPSET rgInitPropSet;
IDataInitialize * pDataInit = NULL;
IDBInitialize * pDataSourceIDBInitialize = NULL;
IDBCreateSession * pSession = NULL;
IDBProperties * pProperties = NULL;
IDBCreateCommand * pCreateCommand = NULL;
ICommand * pCommand = NULL;
ICommandProperties * pCommandProperties = NULL;
ICommandText * pCommandText = NULL;
IOpenRowset * pOpenRowset = NULL;
IRowset * pRowset = NULL;
IRowsetChange * pRowsetChange = NULL;
IDBSchemaRowset * pSchemaRowset =NULL;
WCHAR wszProvider[] = L"MSDASQL"; // The Provider string

CLSID clsid;
HRESULT hr= S_OK;

// Init OLE and set up the data

CoInitialize(NULL);

// Setting up all the properties
// a) Setting up the Intitialization properties

for(long i=0;i<5; i++)
{
InitProperties[i].dwOptions = DBPROPOPTIONS_REQUIRED;
InitProperties[i].colid = DB_NULLID;
InitProperties[i].dwStatus = DBPROPSTATUS_OK;
}

// Data source string.
InitProperties[1].dwPropertyID = DBPROP_INIT_DATASOURCE;
InitProperties[1].colid = DB_NULLID;
InitProperties[1].vValue.vt = VT_BSTR;
InitProperties[1].vValue.bstrVal = SysAllocString(L"user");

InitProperties[4].dwPropertyID = DBPROP_INIT_OLEDBSERVICES;
InitProperties[4].vValue.vt = VT_I4;
InitProperties[4].vValue.lVal = DBPROPVAL_OS_ENABLEALL;

rgInitPropSet.guidPropertySet = DBPROPSET_DBINIT; // the property set
rgInitPropSet.cProperties = 5; // # of properties being set
rgInitPropSet.rgProperties = InitProperties; // array of DBPROP structures

// b) The Rowset properties
InitProperty[0].dwPropertyID = DBPROP_CANFETCHBACKWARDS;
InitProperty[1].dwPropertyID = DBPROP_IRowsetLocate;
for(i=0;i<2; i++)
{
InitProperty[i].dwOptions = DBPROPOPTIONS_REQUIRED;
InitProperty[i].colid = DB_NULLID;
InitProperty[i].dwStatus = DBPROPSTATUS_OK;
}

// 1. Data Source Initialization

hr = CoCreateInstance(CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, IID_IDataInitialize, (void**)&pDataInit);



// Creating the IDBInitialize
hr = CLSIDFromProgID(wszProvider, &clsid);

hr = pDataInit->CreateDBInstance(clsid, NULL, CLSCTX_INPROC_SERVER, NULL, IID_IDBInitialize, (IUnknown**) &pDataSourceIDBInitialize);

// Setting the Initialization properties
hr = pDataSourceIDBInitialize->QueryInterface(IID_IDBProperties, (void**)&pProperties);

hr = pProperties->SetProperties(1,&rgInitPropSet);

hr = pDataSourceIDBInitialize->Initialize( );

hr = pDataInit->Release();

hr = pProperties->Release();


//session creation

hr = pDataSourceIDBInitialize->QueryInterface(IID_IDBCreateSession, (void**)&pSession);

hr = pDataSourceIDBInitialize->Release();
IUnknown *pUnkSession =NULL;

hr = pSession->CreateSession(NULL, IID_IOpenRowset, &pUnkSession);

IDBSchemaRowset * pIDBSchemaRowset = NULL;

// pUnkSession->QueryInterface(IID_IDBSchemaRowset, (void**)&pIDBSchemaRowset);
pSession->Release();

IUnknown * pUnkCommand = NULL;
IOpenRowset * pIOpenRowset = NULL;
WCHAR wszTableName[11] = {0};
DBID TableID;
IUnknown *ppUnkRowset;
IUnknown *ppRowset;
VARIANT rest[]={VT_EMPTY,VT_EMPTY,VT_EMPTY,VT_EMPTY};

::MessageBox(NULL,"Helooo",NULL,MB_OK);
const ULONG cProperties = 2;
DBPROP rgProperties[cProperties];
DBPROPSET rgPropSets[1];

// rgPropSets, cProperties, rgProperties);
//DBPROPSET* pPropSet, ULONG cProperties, DBPROP* rgProperties)
rgPropSets->rgProperties = rgProperties;
rgPropSets->cProperties = cProperties;
rgPropSets->guidPropertySet = DBPROPSET_ROWSET;

rgProperties[0].dwPropertyID = DBPROP_CANFETCHBACKWARDS;
rgProperties[1].dwPropertyID = DBPROP_IRowsetLocate;
for(i=0;i<2; i++)
{
rgProperties[i].dwOptions = DBPROPOPTIONS_REQUIRED;
rgProperties[i].colid = DB_NULLID;
rgProperties[i].dwStatus = DBPROPSTATUS_OK;
}

hr = pSchemaRowset->GetRowset (
NULL,
DBSCHEMA_TABLES,
0,
NULL,
IID_IRowset,
1,
rgPropSets,
&ppRowset);

if(hr==S_OK)
::MessageBox(NULL,"ok",NULL,MB_OK);

if(hr==DB_S_ERRORSOCCURRED )
::MessageBox(NULL,"HI",NULL,MB_OK);

if(hr==DB_S_ASYNCHRONOUS)
::MessageBox(NULL,"HI1",NULL,MB_OK);

//if(hr==DB_S_NOTSINGLETON )
//::MessageBox(NULL,"HI2",NULL,MB_OK);

if(hr==E_FAIL )
::MessageBox(NULL,"HI3",NULL,MB_OK);

if(hr==E_INVALIDARG )
::MessageBox(NULL,"HI4",NULL,MB_OK);

if(hr==E_NOINTERFACE )
::MessageBox(NULL,"HI5",NULL,MB_OK);

if(hr==DB_E_ABORTLIMITREACHED)
::MessageBox(NULL,"HI6",NULL,MB_OK);

if(hr==DB_E_ERRORSOCCURRED)
::MessageBox(NULL,"HI7",NULL,MB_OK);

if(hr==DB_E_NOAGGREGATION)
::MessageBox(NULL,"HI8",NULL,MB_OK);

if(hr==DB_E_NOTFOUND )
::MessageBox(NULL,"HI9",NULL,MB_OK);

if(hr==DB_E_NOTSUPPORTED)
::MessageBox(NULL,"HI10",NULL,MB_OK);

if(hr==DB_SEC_E_PERMISSIONDENIED)
::MessageBox(NULL,"HI11",NULL,MB_OK);

if(hr==DB_E_OBJECTOPEN )
::MessageBox(NULL,"HI12",NULL,MB_OK);

if(hr==E_OUTOFMEMORY )
::MessageBox(NULL,"HI13",NULL,MB_OK);
::MessageBox(NULL,"HIsfsf",NULL,MB_OK);
return S_OK;
}

thanking you.



Gaurav Jain
K.K. Wagh Institue of Engineering Education and Research,
Nashik,
Maharashtra,
India.

gauravjain911@yahoo.com
Generalfft scale factor in MRI Dicom images Pin
ramtilak gattu28-Feb-05 5:34
ramtilak gattu28-Feb-05 5:34 
GeneralRe: fft scale factor in MRI Dicom images Pin
dicomapi27-Apr-05 2:20
dicomapi27-Apr-05 2:20 
Generalimplementing COM in c++ Pin
csharp627-Feb-05 18:19
csharp627-Feb-05 18:19 
GeneralRe: implementing COM in c++ Pin
Anuj Mishra2-Mar-05 18:10
Anuj Mishra2-Mar-05 18:10 
Generaltips on how start mfc &amp; vc++ Pin
yogesh tillu26-Feb-05 5:56
sussyogesh tillu26-Feb-05 5:56 
GeneralRe: tips on how start mfc &amp; vc++ Pin
Anonymous27-Feb-05 2:49
Anonymous27-Feb-05 2:49 
GeneralRe: tips on how start mfc &amp; vc++ Pin
ThatsAlok11-Mar-05 2:09
ThatsAlok11-Mar-05 2:09 
GeneralSysAllocString() allocation Pin
abc87624-Feb-05 22:54
abc87624-Feb-05 22:54 
GeneralRe: SysAllocString() allocation Pin
geo_m26-Feb-05 7:54
geo_m26-Feb-05 7:54 
GeneralRe: SysAllocString() allocation Pin
Jörgen Sigvardsson26-Feb-05 8:05
Jörgen Sigvardsson26-Feb-05 8:05 
Generalwhy my com dll could not be imported Pin
williamchou24-Feb-05 15:26
williamchou24-Feb-05 15:26 
GeneralTlbImp.exe Pin
ursus zeta6-Mar-05 12:11
ursus zeta6-Mar-05 12:11 
GeneralWMI Blues Pin
newbee7824-Feb-05 4:41
newbee7824-Feb-05 4:41 
GeneralStart learning COM Pin
vuthaianh24-Feb-05 0:21
vuthaianh24-Feb-05 0:21 
GeneralRe: Start learning COM Pin
rwestgraham24-Feb-05 11:22
rwestgraham24-Feb-05 11:22 
GeneralRe: Start learning COM Pin
Fragging14-Mar-05 8:31
Fragging14-Mar-05 8:31 
GeneralWord document to stream Pin
jan larsen23-Feb-05 21:34
jan larsen23-Feb-05 21:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.