Click here to Skip to main content
15,915,164 members
Home / Discussions / COM
   

COM

 
QuestionVT_DISPATCH variant Pin
asdtry1-Apr-07 23:57
asdtry1-Apr-07 23:57 
AnswerRe: VT_DISPATCH variant Pin
Vi24-Apr-07 19:04
Vi24-Apr-07 19:04 
QuestionWhere should I call CoUninitialize Pin
Hariom Tiwari1-Apr-07 20:59
Hariom Tiwari1-Apr-07 20:59 
AnswerRe: Where should I call CoUninitialize Pin
prasad_som1-Apr-07 21:34
prasad_som1-Apr-07 21:34 
QuestionHow to create a service Pin
simonr62831-Mar-07 21:05
simonr62831-Mar-07 21:05 
QuestionFull idlist for a folder [modified] Pin
CodeBerserker30-Mar-07 12:13
CodeBerserker30-Mar-07 12:13 
AnswerRe: Full idlist for a folder Pin
CodeBerserker5-Apr-07 10:15
CodeBerserker5-Apr-07 10:15 
Questionissue reading records from SQL CE 2005 Pin
vvr198329-Mar-07 23:18
vvr198329-Mar-07 23:18 
I have written a class for operating the SQLCE database with OLE DB, it work perfect on INSERT ,UPTDATE and so on, but when I use 'select' statement to get values from database it doesn’t return values properly even though the GetNextRows method succeeds.

HRESULT hr = NOERROR;
m_pIRowset = NULL;
m_prghRows = &m_rghRows[0];
hr = pICmdText->SetCommandText(DBGUID_SQL, pwszQuery);
if(!FAILED(hr))
{
hr = pICmdText->Execute(NULL, IID_IRowset, NULL, NULL, (IUnknown **)&m_pIRowset);
if (FAILED(hr)){
AfxMessageBox(_T("failed"));
m_pIRowset = NULL;
}
// Get IColumnsInfo interface
hr = m_pIRowset->QueryInterface(IID_IColumnsInfo, (void**)&m_pIColumnsInfo);
if(FAILED(hr)){
AfxMessageBox(_T("failed"));
}
// Get the column metadata m_ulNumCols//m_pDBColumnInfo
hr = m_pIColumnsInfo->GetColumnInfo(&m_ulNumCols, &m_pDBColumnInfo,&m_pStringsBuffer);
if(FAILED(hr) || 0 == m_ulNumCols){
AfxMessageBox(_T("failed"));
}
// Create a DBBINDING array.
m_dwBindingSize = m_ulNumCols;
m_prgBinding = (DBBINDING*)CoTaskMemAlloc(sizeof(DBBINDING)*m_dwBindingSize);
if (NULL == m_prgBinding){
hr = E_OUTOFMEMORY;
AfxMessageBox(_T("Memory allocation failure"));
}
// Set initial offset for binding position
m_dwOffset = 0;
// Prepare structures to create the accessor
UINT lCount;
ULONG dwOrdinal;
for (lCount = 0; lCount< m_ulNumCols; lCount++)
{
dwOrdinal = m_pDBColumnInfo[lCount].iOrdinal;
m_prgBinding[lCount].iOrdinal = dwOrdinal;
m_prgBinding[lCount].dwPart = DBPART_VALUE | DBPART_STATUS | DBPART_LENGTH;
m_prgBinding[lCount].obLength = m_dwOffset;
m_prgBinding[lCount].obStatus = m_prgBinding[lCount].obLength + sizeof(ULONG);
m_prgBinding[lCount].obValue = m_prgBinding[lCount].obStatus + sizeof(DBSTATUS);
m_prgBinding[lCount].wType = m_pDBColumnInfo[lCount].wType;
m_prgBinding[lCount].pTypeInfo = NULL;
m_prgBinding[lCount].pObject = NULL;
m_prgBinding[lCount].pBindExt = NULL;
m_prgBinding[lCount].dwMemOwner = DBMEMOWNER_CLIENTOWNED;
m_prgBinding[lCount].dwFlags = 0;
m_prgBinding[lCount].bPrecision = m_pDBColumnInfo[lCount].bPrecision;
m_prgBinding[lCount].bScale = m_pDBColumnInfo[lCount].bScale;
switch(m_prgBinding[lCount].wType){
case DBTYPE_WSTR:
m_prgBinding[lCount].cbMaxLen = sizeof(WCHAR)*(m_pDBColumnInfo[lCount].ulColumnSize + 1); // Extra buffer for null terminator
break;
default:
m_prgBinding[lCount].cbMaxLen = m_pDBColumnInfo[lCount].ulColumnSize;
break;
}
// Calculate the offset, and properly align it
m_dwOffset = m_prgBinding[lCount].obValue + m_prgBinding[lCount].cbMaxLen;
m_dwOffset = ROUND_UP(m_dwOffset, 8);
}
// Get IAccessor interface
hr = m_pIRowset->QueryInterface(IID_IAccessor, (void**)&m_pIAccessor);
if(FAILED(hr))
{
AfxMessageBox(_T("failed"));
}
// Create the accessor
//
hr = m_pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, m_dwBindingSize,
m_prgBinding, 0, &m_hAccessor,NULL);
if(FAILED(hr))
{
AfxMessageBox(_T("failed"));
}
// Allocate data buffer.
//
m_pData = (BYTE*)CoTaskMemAlloc(m_dwOffset);
if (NULL == m_pData)
{
hr = E_OUTOFMEMORY;
CString errors;
errors.Format(_T("%d"),m_pDBColumnInfo[2].ulColumnSize);
MessageBox(NULL,errors,NULL,MB_OK);
AfxMessageBox(_T("failed"));
}
// Retrive a row
//
hr = m_pIRowset->GetNextRows(DB_NULL_HCHAPTER, 0, 1, &m_cRowsObtained,&m_prghRows);
if (SUCCEEDED(hr) && hr != DB_S_ENDOFROWSET)
{
// Set data buffer to zero
//
memset(m_pData, 0, m_dwOffset);

// Fetch actual data
hr = m_pIRowset->GetData(m_prghRows[0], m_hAccessor, m_pData);

if (FAILED(hr))
{
m_pIRowset->ReleaseRows(1, m_prghRows, NULL, NULL, NULL);
AfxMessageBox(_T("failed"));
}
}
if (hr == DB_S_ENDOFROWSET)
{
m_bIsEOF = TRUE;
}
}

venkat
QuestionExcel Interop Issues Pin
Steven M Hunt29-Mar-07 10:25
Steven M Hunt29-Mar-07 10:25 
AnswerRe: Excel Interop Issues Pin
Phillip M. Hoff31-Mar-07 16:26
Phillip M. Hoff31-Mar-07 16:26 
QuestionMicrosoft word Pin
Amr M. K.29-Mar-07 2:15
Amr M. K.29-Mar-07 2:15 
QuestionCreate a COM component and use in my application Pin
Malayil alex28-Mar-07 19:51
Malayil alex28-Mar-07 19:51 
AnswerRe: Create a COM component and use in my application Pin
prasad_som28-Mar-07 20:02
prasad_som28-Mar-07 20:02 
AnswerRe: Create a COM component and use in my application Pin
lafleon30-Mar-07 14:33
lafleon30-Mar-07 14:33 
QuestionHELP NEEDED - DCOM Server in C#? Pin
r6yamaha28-Mar-07 11:58
r6yamaha28-Mar-07 11:58 
AnswerRe: HELP NEEDED - DCOM Server in C#? Pin
lafleon30-Mar-07 14:38
lafleon30-Mar-07 14:38 
GeneralRe: HELP NEEDED - DCOM Server in C#? Pin
r6yamaha31-Mar-07 4:59
r6yamaha31-Mar-07 4:59 
QuestionIInputObject breaking from VS 2003 to VS 2005? Pin
Christopher Duncan28-Mar-07 11:30
Christopher Duncan28-Mar-07 11:30 
QuestionQuestion about ATL / COM - add and control Composite control Pin
Yanshof27-Mar-07 19:15
Yanshof27-Mar-07 19:15 
QuestionI want to Write a ATL COM to hold the Event "a NewMail button on Standard toolbar of Outlook is pressed" Pin
bk_eminem27-Mar-07 18:10
bk_eminem27-Mar-07 18:10 
QuestionHelp!!! How to Add MS Visio Event in Unmanaged MFC? Pin
iomosi27-Mar-07 4:30
iomosi27-Mar-07 4:30 
QuestionCreating MPEG-1 from series of JPEG Pin
yudhisthira27-Mar-07 1:04
yudhisthira27-Mar-07 1:04 
QuestionMaking COM+ application [modified] Pin
Vlad~26-Mar-07 23:42
Vlad~26-Mar-07 23:42 
QuestionWithout ClassID Pin
_808625-Mar-07 23:52
_808625-Mar-07 23:52 
GeneralRe: Without ClassID [modified] Pin
Stephen Hewitt26-Mar-07 13:32
Stephen Hewitt26-Mar-07 13:32 

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.