Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

83 lines
2.1 KiB

///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 1998, Microsoft Corp. All rights reserved.
//
// FILE
//
// bind.cpp
//
// SYNOPSIS
//
// This file defines various helper functions for binding an OLE-DB
// accessor to the members of a class.
//
// MODIFICATION HISTORY
//
// 02/20/1998 Original version.
//
///////////////////////////////////////////////////////////////////////////////
#include <ias.h>
#include <oledb.h>
#include <bind.h>
DBLENGTH Bind::getRowSize(
DBCOUNTITEM cBindings,
const DBBINDING rgBindings[]
) throw ()
{
DBLENGTH rowSize = 0;
while (cBindings--)
{
DBLENGTH end = rgBindings->obValue + rgBindings->cbMaxLen;
if (end > rowSize) { rowSize = end; }
++rgBindings;
}
return rowSize;
}
HACCESSOR Bind::createAccessor(IUnknown* pUnk,
DBACCESSORFLAGS dwAccessorFlags,
DBCOUNTITEM cBindings,
const DBBINDING rgBindings[],
DBLENGTH cbRowSize)
{
using _com_util::CheckError;
CComPtr<IAccessor> accessor;
CheckError(pUnk->QueryInterface(__uuidof(IAccessor), (PVOID*)&accessor));
HACCESSOR h;
CheckError(accessor->CreateAccessor(dwAccessorFlags,
cBindings,
rgBindings,
cbRowSize,
&h,
NULL));
return h;
}
// Releases an accessor on the pUnk object.
void Bind::releaseAccessor(IUnknown* pUnk, HACCESSOR hAccessor) throw ()
{
if (pUnk && hAccessor)
{
IAccessor* accessor;
HRESULT hr = pUnk->QueryInterface(__uuidof(IAccessor),
(PVOID*)&accessor);
if (SUCCEEDED(hr))
{
accessor->ReleaseAccessor(hAccessor, NULL);
accessor->Release();
}
}
}