Click here to Skip to main content
15,916,371 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
Generaldyanamically create listboxes Pin
gauravjain1-Mar-05 4:31
gauravjain1-Mar-05 4:31 
Generalcode to retrieve window xp's user name Pin
tkarven1-Mar-05 3:53
tkarven1-Mar-05 3:53 
GeneralRe: code to retrieve window xp's user name Pin
Michael Dunn1-Mar-05 7:48
sitebuilderMichael Dunn1-Mar-05 7:48 
GeneralRe: code to retrieve window xp's user name Pin
tkarven1-Mar-05 20:59
tkarven1-Mar-05 20:59 
GeneralRe: code to retrieve window xp's user name Pin
Michael Dunn2-Mar-05 12:16
sitebuilderMichael Dunn2-Mar-05 12:16 
Generalview image in IE's context menu Pin
tkarven1-Mar-05 0:56
tkarven1-Mar-05 0:56 
GeneralRe: view image in IE's context menu Pin
tkarven1-Mar-05 1:11
tkarven1-Mar-05 1:11 
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
GeneralWTL shows compile time error Pin
inbakumar.G27-Feb-05 19:08
inbakumar.G27-Feb-05 19:08 
GeneralRe: WTL shows compile time error Pin
Stuart Dootson27-Feb-05 22:12
professionalStuart Dootson27-Feb-05 22:12 
GeneralRe: WTL shows compile time error Pin
inbakumar.G27-Feb-05 22:20
inbakumar.G27-Feb-05 22:20 
GeneralRe: WTL shows compile time error Pin
Stuart Dootson27-Feb-05 22:26
professionalStuart Dootson27-Feb-05 22:26 
GeneralRe: WTL shows compile time error Pin
inbakumar.G27-Feb-05 22:35
inbakumar.G27-Feb-05 22:35 
GeneralRe: WTL shows compile time error Pin
Michael Dunn28-Feb-05 7:59
sitebuilderMichael Dunn28-Feb-05 7:59 
GeneralSharing a variable between Pin
sameeraperera27-Feb-05 5:16
sameeraperera27-Feb-05 5:16 
GeneralRe: Sharing a variable between Pin
Kevin Tambascio7-Mar-05 4:18
Kevin Tambascio7-Mar-05 4:18 
QuestionHow to catch events? Pin
Roozbeh6926-Feb-05 20:16
professionalRoozbeh6926-Feb-05 20:16 
AnswerRe: How to catch events? Pin
Stuart Dootson27-Feb-05 3:17
professionalStuart Dootson27-Feb-05 3:17 
GeneralRe: How to catch events? Pin
Roozbeh6927-Feb-05 22:43
professionalRoozbeh6927-Feb-05 22:43 
GeneralWTL can support Virus Program Pin
25-Feb-05 18:26
suss25-Feb-05 18:26 
GeneralRe: WTL can support Virus Program Pin
Tarundeep Singh Kalra4-Mar-05 8:33
Tarundeep Singh Kalra4-Mar-05 8:33 
GeneralATL control Pin
muslcesonvacation25-Feb-05 15:15
muslcesonvacation25-Feb-05 15:15 
Generaldialog display failure Pin
tkarven24-Feb-05 0:56
tkarven24-Feb-05 0:56 
GeneralRe: dialog display failure Pin
devom25-Feb-05 20:23
devom25-Feb-05 20:23 
GeneralRe: dialog display failure Pin
tkarven26-Feb-05 1:40
tkarven26-Feb-05 1:40 

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.