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

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // bind.cpp
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file defines various helper functions for binding an OLE-DB
  12. // accessor to the members of a class.
  13. //
  14. // MODIFICATION HISTORY
  15. //
  16. // 02/20/1998 Original version.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #include <ias.h>
  20. #include <oledb.h>
  21. #include <bind.h>
  22. DBLENGTH Bind::getRowSize(
  23. DBCOUNTITEM cBindings,
  24. const DBBINDING rgBindings[]
  25. ) throw ()
  26. {
  27. DBLENGTH rowSize = 0;
  28. while (cBindings--)
  29. {
  30. DBLENGTH end = rgBindings->obValue + rgBindings->cbMaxLen;
  31. if (end > rowSize) { rowSize = end; }
  32. ++rgBindings;
  33. }
  34. return rowSize;
  35. }
  36. HACCESSOR Bind::createAccessor(IUnknown* pUnk,
  37. DBACCESSORFLAGS dwAccessorFlags,
  38. DBCOUNTITEM cBindings,
  39. const DBBINDING rgBindings[],
  40. DBLENGTH cbRowSize)
  41. {
  42. using _com_util::CheckError;
  43. CComPtr<IAccessor> accessor;
  44. CheckError(pUnk->QueryInterface(__uuidof(IAccessor), (PVOID*)&accessor));
  45. HACCESSOR h;
  46. CheckError(accessor->CreateAccessor(dwAccessorFlags,
  47. cBindings,
  48. rgBindings,
  49. cbRowSize,
  50. &h,
  51. NULL));
  52. return h;
  53. }
  54. // Releases an accessor on the pUnk object.
  55. void Bind::releaseAccessor(IUnknown* pUnk, HACCESSOR hAccessor) throw ()
  56. {
  57. if (pUnk && hAccessor)
  58. {
  59. IAccessor* accessor;
  60. HRESULT hr = pUnk->QueryInterface(__uuidof(IAccessor),
  61. (PVOID*)&accessor);
  62. if (SUCCEEDED(hr))
  63. {
  64. accessor->ReleaseAccessor(hAccessor, NULL);
  65. accessor->Release();
  66. }
  67. }
  68. }