Page 22 of 693« First...10...2021222324...304050...Last »

MSExchangeIS Mailbox Messages Queued for Submission keeps increasing in an Exchange Server environment

In a Microsoft Exchange Server 2007 or Exchange Server 2010 environment, the MSExchangeIS Mailbox Messages Queued for Submission performance counter keeps increasing.
When the MailSubmission service submits a message for delivery multiple times, the counter is incremented two times but decremented only one time. This situation can leave the counter with a positive value even though there is no message in the queue. When you restart the service, the counter is reset. 
This is a known issue with Exchange Server 2007 and Exchange Server 2010.  We do not recommend that you use this counter for health alerts.

Article ID: 2921142 – Last Review: January 3, 2014 – Revision: 1.0


Applies to
  • Microsoft Exchange Server 2007 Enterprise Edition
  • Microsoft Exchange Server 2007 Standard Edition
  • Microsoft Exchange Server 2010 Enterprise
  • Microsoft Exchange Server 2010 Standard
kbsurveynew kbtshoot kbexpertiseinter KB2921142

See more here:
MSExchangeIS Mailbox Messages Queued for Submission keeps increasing in an Exchange Server environment

Retention policies aren’t applied when you move a mailbox to on-premises Exchange 2013 or Exchange Online in Office 365

Log Name: Application
Source: MSExchangeMailboxAssistants
Date:
Event ID: 10021
Task Category: Managed Folder Assistant
Level: Error
Keywords: Classic
User: N/A
Computer:

Description:
The MRM Assistant will skip processing mailbox ‘OW4:5c3790e2-4ec2-4510-b8b7-5bc861e92533:. Exception details: ‘Microsoft.Exchange.Assistants.TransientMailboxException —> Microsoft.Exchange.InfoWorker.Common.ELC.ELCFolderSyncException:
Failed to synchronize the messaging records management settings on managed folder Managed Folders in mailbox with the settings in Active Directory.
at Microsoft.Exchange.InfoWorker.Common.ELC.ProvisionedFolderCreator.SaveELCFolder(Folder folder, Boolean create)
at Microsoft.Exchange.InfoWorker.Common.ELC.ElcMailboxHelper.RemoveElcFolder(Boolean userIsOnRetentionPolcyTags, MailboxSession mailboxSession, StoreId folderId, Dictionary`2 allAdTags, UpgradeStatus& status)
at Microsoft.Exchange.InfoWorker.Common.ELC.ElcMailboxHelper.ScrubElcMailbox(Boolean userIsOnRetentionPolcyTags, MailboxSession mailboxSession, Dictionary`2 allAdTags, UpgradeStatus& status)
at Microsoft.Exchange.MailboxAssistants.Assistants.ELC.TagProvisioner.InvokeInternal(MailboxDataForTags mailboxDataForTags)
at Microsoft.Exchange.MailboxAssistants.Assistants.ELC.TagProvisioner.Invoke(MailboxDataForTags mailboxDataForTags)
at Microsoft.Exchange.MailboxAssistants.Assistants.ELC.ElcTagSubAssistant.InvokeInternal(MailboxSession mailboxSession, MailboxDataForTags mailboxDataForTags)
at Microsoft.Exchange.MailboxAssistants.Assistants.ELC.ElcTagSubAssistant.Invoke(MailboxSession mailboxSession, MailboxDataForTags mailboxDataForTags)
at Microsoft.Exchange.MailboxAssistants.Assistants.ELC.ELCAssistant.InvokeCore(MailboxSession mailboxSession, StatisticsLogEntry logEntry, ElcParameters parameters)
at Microsoft.Exchange.Common.IL.ILUtil.DoTryFilterCatch(TryDelegate tryDelegate, FilterDelegate filterDelegate, CatchDelegate catchDelegate)

Read more here:
Retention policies aren’t applied when you move a mailbox to on-premises Exchange 2013 or Exchange Online in Office 365

Attendee exceptions to a recurring event are incorrectly displayed in Outlook

Consider the following scenario:
  1. You create an appointment or a meeting in Microsoft Office Outlook.
  2. You add users as attendees to this event, and then you set the event to be recurring.
  3. All the users accept the invitation.
  4. As the organizer, you select a single occurrence of this event, and then you switch to Scheduling Assistant view.
  5. You make exceptions to the All Attendees list by clearing the check boxes next to names of some users.
  6. You save the changes, and then you send the invitation to all users.
  7. You log in to the calendar of one of the users that you had removed from the invitation, and then you click Remove from calendar.

    Note This step is optional. This issue seems to occur regardless of whether you take this action.

  8. A user who is an attendee starts Outlook, and then views the same occurrence of the event.

In this scenario, the user who views the event sees all the original invitees to the event. This includes those users who had been removed from the event. The other attendees are displayed as being either Free or Busy depending on whether they were or were not removed from the event.

To resolve this issue, follow these steps: 
  1. Change the AutomateProcessing parameter from AutoUpdate to None. To do this, run the following command:
    Set-CalendarProcessing -identity alias -AutomateProcessing None

    Note In this cmdlet, alias represents the actual identity value of the mailbox.

  2. In the calendar invitation, delete the the users who you do not want to invite to the event.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the “Applies to” section.

Article ID: 2909601 – Last Review: December 27, 2013 – Revision: 1.0


Applies to
  • Microsoft Exchange Server 2010 Service Pack 3

More here:
Attendee exceptions to a recurring event are incorrectly displayed in Outlook

"The rules on this computer do not match the rules on Microsoft Exchange" error when you manage rules by using Outlook 2013 in an Exchange Server 2010 environment

oneMscomBlade,oneMsomNav,oneMscomFooter,

More:
"The rules on this computer do not match the rules on Microsoft Exchange" error when you manage rules by using Outlook 2013 in an Exchange Server 2010 environment

SAMPLE: Sqlfstin: Speed Up OLE DB Inserts By Using IRowsetFastLoad()

The Sqlfstin.exe sample demonstrates how to perform quick,
transactional inserts of a large number of records into SQL Server by using the
IRowsetFastLoad interface and the ATL OLE DB consumer templates. The sample also
shows how to roll back such transactions.
The
following file is available for download from the Microsoft Download
Center:
Sqlfstin.exe

(http://download.microsoft.com/download/vc60pro/sample/2/W9XNT4/EN-US/sqlfstin.exe)

Release Date: Feb. 18,
2000

For additional information about how to download Microsoft
Support files, click the following article number to view the article in the
Microsoft Knowledge Base:

119591

(http://support.microsoft.com/kb/119591/EN-US/
)

How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help to
prevent any unauthorized changes to the file.

In some instances, the wizard-generated ATL
consumer code that uses IRowsetChange may not provide sufficient performance when a large number of
inserts are made. To increase the performance, the IRowsetFastLoad interface may be used.

Steps to Run the Sample

  1. Run the Setuptable.sql script with SQL Server 7.0 to create
    the table in the Pubs database.
  2. Modify the DBPROP_INIT_DATASOURCE property to make sure
    that it points to the right datasource. If you don’t use Microsoft Windows NT
    integrated security, you also need to add the property on UID and
    PWD.
  3. Compile and run the application. When the dialog box is
    displayed, type in the number of records you want to insert into the table (the
    default is 10,000), and then click either Use SQLOLEDB, Use MSDASQL, or Use IRowsetFastLoad, which uses IRowsetFastLoad to perform the insertions. Near the Use IRowsetFastLoad button is a Commit check box. This check box only affects the IRowsetFastLoad functionality. When selected, the intended functionality is to
    show how to commit the IRowsetFastLoad transaction by calling CdboTestTable3::FastCommit.

    NOTE: If the Commit check box is not selected when using IRowsetFastLoad, the inserts are never committed so the whole transaction is in
    effect rolled back.

  4. To verify the performance difference between the indexed
    table and the non-indexed table, run the Sqladdindex.sql script to create an
    index on the table. Rerun the application and compare the results.

Steps to Use the Sample

  1. To use the IRowsetFastLoad interface, you must set the SQLOLEDB provider-specific data
    source property SSPROP_ENABLEFASTLOAD to VARIANT_TRUE. If you use code
    generated by the wizard, you must manually add this property. See the sample
    code for details.
  2. When you set ENABLEFASTLOAD on the datasource or
    connection, this property is propagated to the session object. The new session
    allows the consumer access to the IRowsetFastLoad interface. However, this also means that you cannot open another
    standard consumer rowset on this session because none of the interfaces exposed
    by this session object (for information on interfaces, see the SQL books
    online) supports opening a standard consumer rowset because it requires IDBCreateCommand.
  3. You can still open a standard rowset but you cannot reuse
    the session object. In order to reuse the session object, make the following
    call, which resets the ENABLEFASTLOAD property on the connection object. The
    benefit is that thereafter, each newly opened session object will have default
    session properties without having to re-create the datasource or the
    connection:
             session.Close();
    	dso.AddProperty(SSPROP_ENABLEFASTLOAD, false);
    	hr = pIDBProps->SetProperties(1, &dso);
    	session.Open(connection);
    						

  4. You cannot fast-load into multiple tables at the same time
    by using IRowsetFastLoad, which is the interface to the SQL Server bulk copy component.
    You need to commit the previous fast load before you start a new one because
    the overlapped transaction is not allowed when doing bulk copy.
For additional information,
click the article number below to view the article in the Microsoft Knowledge
Base:
246265

(http://support.microsoft.com/kb/246265/EN-US/
)

Slow Inserts When Using SQLOLEDB Provider

(c) Microsoft Corporation 1999, All Rights
Reserved. Contributions by Thomas Klevmar, Microsoft Corporation.

Article ID: 246262 – Last Review: December 27, 2013 – Revision: 5.0


Applies to
  • Microsoft Data Access Components 2.1
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7
kbdownload kbdatabase kbdtl kbhowto kbsample KB246262

More here:
SAMPLE: Sqlfstin: Speed Up OLE DB Inserts By Using IRowsetFastLoad()

ATLShape.exe: Retrieve Hierarchical Data in an ATL OLE DB Consumer Through the MSDataShape Provider

The ATLShape.exe sample demonstrates how to retrieve
hierarchical data by using the MSDataShape provider. The sample reads data from
either a Microsoft Access 97 database or a SQL Server 7.0 database, and writes
it to an Example.out text file.

Active Template Library (ATL) OLE DB
Consumer Libraries do not provide support for hierarchical queries. The
ATLShape.exe sample provides an ATL OLE DB CMyRowset class that is derived from
CRowset, and that incorporates support for hierarchical queries.

The
following file is available for download from the Microsoft Download
Center:
ATLShape.exe

(http://download.microsoft.com/download/vc60ent/sample/1/WIN98/EN-US/atlshape.exe)

Release Date:
1-14-2000

For additional information about how to download Microsoft
Support files, click the following article number to view the article in the
Microsoft Knowledge Base:

119591

(http://support.microsoft.com/kb/119591/EN-US/
)

How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help to
prevent any unauthorized changes to the file.

The ATLShape.exe file contains the following
files:

Collapse this tableExpand this table

File Name Size
ATLShape.cpp 15KB
Test.mdb 454KB
Readme.txt 15KB

The ATLShape.exe sample allows the user to read from
either the Access 97 Test.mdb database or from a local SQL Server 7.0 Northwind
database. The hierarchical output is written to an Example.out text file. This
is achieved by setting up an appropriate connection string for
each:

For the Access 97 Database:

connection.OpenFromInitializationString(L"Provider=MSDataShape.1;Persist Security Info=False;
Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.Test.mdb")

For the SQL Server 7.0 Database:

connection.OpenFromInitializationString(L"Provider=MSDataShape.1;Persist Security Info=False;
Data Provider=SQLOLEDB;Database=Northwind;Server=MySQLServer7;uid=sa;pwd=")
				

ATLShape also creates a CMyRowset class that is derived from the CRowset class. The CRowset class is provided by ATL OLE DB template libraries, which provide
the ability to perform hierarchical queries. This class maintains an m_hChapter
HCHAPTER variable that stores the HCHAPTER data type of the chaptered column in
the parent that is currently being accessed.

The child rowset is
obtained by performing an IRowsetInfo::GetReferencedRowset method on the chaptered column as follows:

CComPtr spChildRowset;
CComPtr spUnkRowset;
CComPtr spParent;
cLocalCommand.m_spRowset->QueryInterface(&spParent);
spParent->GetReferencedRowset(colNo, __uuidof(IRowset), &spUnkRowset);
spUnkRowset->QueryInterface(&spChildRowset);
				

In addition, an ATLOutputData template function is provided that reads
data from class rowsetClass and writes it to the FILE* that is passed to it:

template 
HRESULT ATLOutputData(rowsetClass &Rs, dataSource &db , FILE *fptr); 

To retrieve data from the chaptered column, perform the following
steps:

  1. Instantiate the CMyRowset class:
    CAccessorRowset tmpRowset;

  2. Assign the m_spRowset variable to contain the child rowset:
    tmpRowset.m_spRowset = pChildIRowset;

  3. Assign the m_hChapter variable to the appropriate chaptered
    column:
    tmpRowset.m_hChapter = *(HCHAPTER*) LocalCommand.GetValue(_bstr_t( L"EmpOrders"));

  4. Bind the output columns:
  5. Retrieve the data for the first row of the chaptered
    column:
    hr = tmpRowset.MoveFirst();

  6. Retrieve all the data from the child and write it to the
    file:
    hr = ATLOutputData(tmpRowset,*dummy,fptr);

Steps to Run the Application

  1. Create an empty Win32 console application.
  2. Insert the ATLShape.cpp file into the project.
  3. Copy the Test.mdb file into the project folder.
  4. Compile and run the application.

Article ID: 247003 – Last Review: December 27, 2013 – Revision: 5.0


Applies to
  • Microsoft Data Access Components 2.1
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7
kbdatabase kbdtl kbfile kbinfo kbsample KB247003

Link:
ATLShape.exe: Retrieve Hierarchical Data in an ATL OLE DB Consumer Through the MSDataShape Provider

PRB: DB_E_BADBINDINFO Returned from MoveNext/GetData When Using BYREF with Column Type

When using the ATL OLE DB Consumer Templates and specifying DBTYPE_BYREF for the data type for a column entry, MoveNext returns DB_E_BADBINDINFO. More specifically, internally IRowset::GetData is called and it returns the error. The column map may resemble the following:

BEGIN_COLUMN_MAP(CMyTableAccessor)
    COLUMN_ENTRY(1, m_field1)
    COLUMN_ENTRY_EX(2, DBTYPE_STR | DBTYPE_BYREF, sizeof(char *),
                    0, 0, m_pszField2, m_nField2Len, m_Field2Status)
END_COLUMN_MAP()
				

The OLE DB provider is doing deferred accessor validation and is finding values of the DBBINDING structure, which it doesn’t support. Specifically, Active Template Library (ATL) is setting the dwMemOwner member of the DBBINDING structure to DBMEMOWNER_PROVIDEROWNED whenever the developer specifies DBTYPE_BYREF. This is done so that the consumer doesn’t have the responsibility to free the memory returned by the provider. When ReleaseRows is called in the MoveNext method, the memory is automatically freed by the provider. However, according to the OLE DB specification:

For bindings in row accessors, consumer-owned memory must be used unless
wType is DBTYPE_BSTR, X | DBTYPE_BYREF, X | DBTYPE_ARRAY, or X |
DBTYPE_VECTOR, in which cases either consumer-owned or provider-owned
memory can be used. However, the provider might not support using
provider-owned memory to retrieve columns for which
IColumnsInfo::GetColumnInfo returns DBCOLUMNFLAGS_ISLONG for the column.

ODBC OLE DB Provider is one such provider that doesn’t support DBMEMOWNER_PROVIDEROWNED on DBCOLUMNFLAGS_ISLONG columns. As a result, the error is returned when a SQL Server column type of “text” is used, for example, and DBTYPE_BYREF is specified (which causes ATL to set dwMemOwner to DBMEMOWNER_PROVIDEROWNED).

The type DBTYPE_BYREF can still be used, but modifications must be made to the ATL code to prevent it from setting the the DBBINDING structure to DBMEMOWNER_PROVIDEROWNED. Furthermore, if you do specify DBMEMOWNER_CLIENTOWNED and use DBTYPE_BYREF, the consumer is responsible for freeing the memory referenced by using IMalloc::Free/CoTaskMemFree.

The easiest way to work around this problem is to copy the Atldbcli.h file into your project so that you have your own custom build of the header. Modify the Bind method of CAccessorBase by commenting the code that sets the dwMemOwner member to DBMEMOWNER_PROVIDEROWNED. For example:


static void Bind(DBBINDING* pBinding, ULONG nOrdinal, DBTYPE wType,
ULONG nLength, BYTE nPrecision, BYTE nScale, DBPARAMIO eParamIO,
ULONG nDataOffset, ULONG nLengthOffset = NULL, ULONG nStatusOffset = NULL,
DBOBJECT* pdbobject = NULL)

   ATLASSERT(pBinding != NULL);
// If we are getting a pointer to the data, then let the provider
// own the memory.
// if (wType & DBTYPE_BYREF)
// pBinding->dwMemOwner = DBMEMOWNER_PROVIDEROWNED;
// else
   pBinding->dwMemOwner = DBMEMOWNER_CLIENTOWNED;
				

Use this header file instead of the Visual C++ copy.

NOTE: You must free the memory returned to you by the provider. You may want to create a function called FreeRecordMemory() in your class where you call CoTaskMemFree on any of the pointers you get back with BYREF. For example:

void FreeRecordMemory()

  CoTaskMemFree((BYTE *)m_pszField2);

If you don’t want to modify the header file, there is a more difficult approach to work around this problem. You can write your own macro that calls your own Bind function, and that always sets pBinding->dwMemOwner = DBMEMOWNER_CLIENTOWNED.
The code for your data class might resemble the following:

#define _COLUMN_ENTRY_CODE_BYREF(nOrdinal, wType, nLength, nPrecision, nScale, dataOffset, lengthOffset, statusOffset)
	if (pBuffer != NULL)  

		CAccessorBase::FreeType(wType, pBuffer + dataOffset);  

	else if (pBinding != NULL)  

		Bind(pBinding, nOrdinal, wType, nLength, nPrecision, nScale, eParamIO,
			dataOffset, lengthOffset, statusOffset);
		pBinding++;  

	nColumns++;
#define COLUMN_ENTRY_EX_BYREF(nOrdinal, wType, nLength, nPrecision, nScale, data, length, status)
	_COLUMN_ENTRY_CODE_BYREF(nOrdinal, wType, nLength, nPrecision, nScale, offsetbuf(data), offsetbuf(length), offsetbuf(status))

class CdbotexttestAccessor

public:
    TCHAR m_szfield111;
    char * m_pszField2;
    long m_nField2Len;
    DBSTATUS m_Field2Status; 

   static void Bind(DBBINDING* pBinding, ULONG nOrdinal, DBTYPE wType,
         ULONG nLength, BYTE nPrecision, BYTE nScale, DBPARAMIO eParamIO,
         ULONG nDataOffset, ULONG nLengthOffset = NULL, ULONG nStatusOffset = NULL,
         DBOBJECT* pdbobject = NULL)

      ATLASSERT(pBinding != NULL);
      // If we are getting a pointer to the data, then let the provider
      // own the memory.
      // (wType & DBTYPE_BYREF)
      // pBinding->dwMemOwner = DBMEMOWNER_PROVIDEROWNED;
      // else

      pBinding->dwMemOwner = DBMEMOWNER_CLIENTOWNED;
      pBinding->pObject = pdbobject;
      pBinding->eParamIO = eParamIO;
      pBinding->iOrdinal = nOrdinal;
      pBinding->wType = wType;
      pBinding->bPrecision = nPrecision;
      pBinding->bScale = nScale;
      pBinding->dwFlags = 0;
      pBinding->obValue = nDataOffset;
      pBinding->obLength = 0;
      pBinding->obStatus = 0;
      pBinding->pTypeInfo = NULL;
      pBinding->pBindExt = NULL;
      pBinding->cbMaxLen = nLength;
      pBinding->dwPart = DBPART_VALUE;
      if (nLengthOffset != NULL)

         pBinding->dwPart
      if (nStatusOffset != NULL)

         pBinding->dwPart
   } 

   void FreeRecordMemory()

      CoTaskMemFree((BYTE *)m_pField2);

   BEGIN_COLUMN_MAP(CdbotexttestAccessor)
   COLUMN_ENTRY(1, m_szField1)
   COLUMN_ENTRY_EX_BYREF(2, DBTYPE_STR | DBTYPE_BYREF, sizeof(char *), 0, 0, m_pszField2, m_szField2Len, m_szField2Status)
   END_COLUMN_MAP()
};
				

You still can use BYREF, however, you must specify client owned by modifying the ATL code. You are also responsible for freeing the memory using IMalloc::Free/CoTaskMemFree.

This behavior is by design.

Steps to Reproduce Behavior

  1. Create a SQL Server 7.0 table that has a “text” datatype field and insert some records.
  2. Create an MFC application and use the ATL Consumer wizard to generate a CCommand-derived class for the SQL Server table you just created. Use the OLE DB provider for ODBC.
  3. Modify the column map entry for the “text” field to use COLUMN_ENTRY_EX so that it uses DBTYPE_STR | DBTYPE_BYREF.
  4. Add code to the project that creates an instance of the CCommand-derived class and that calls Open followed by a call to MoveNext.
  5. Build and run the application and check the return value of the MoveNext method (it should have a value of DB_E_BADBINDINFO).

Article ID: 242956 – Last Review: December 27, 2013 – Revision: 3.0


Applies to
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7
kbdatabase kbprb KB242956

Read More:
PRB: DB_E_BADBINDINFO Returned from MoveNext/GetData When Using BYREF with Column Type

OleDbOrc.exe: Using the OLE DB Cursor Engine Service to Provide Updatability for OLE DB Providers

Some OLE DB providers, such as Microsoft’s Oracle OLE DB
Provider, do not support updating via IRowsetChange, although they do support
updating via SQL UPDATE statements. In this case, the OLE DB Cursor Engine
service can be used to allow the provider to be updatable via
IRowsetChange.

OleDbOrc.exe is a self-extracting executable
containing two files, SDKServiceSample.cpp and VCServiceSample.cpp, that
demonstrate how to invoke the OLE DB services when using the Oracle OLE DB
Provider so that you can get the IRowsetChange interface and perform updates,
insertions, or deletions.

SDKServiceSample.cpp uses OLE DB SDK
function calls while VCServiceSample.cpp uses the OLE DB Consumer template C++
classes.

To build the samples, bring the .cpp file into the Visual
C++ development environment and choose Build. The program will ask whether you want a default workspace
created, choose Yes.

The
following files are available for download from the Microsoft Download
Center:
OleDBorc.exe

(http://download.microsoft.com/download/dasdk/sample3/1/W9XNT4/EN-US/OLEDBORC.EXE)

For
additional information about how to download Microsoft Support files, click the
following article number to view the article in the Microsoft Knowledge Base:

119591

(http://support.microsoft.com/kb/119591/EN-US/
)

How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help to
prevent any unauthorized changes to the file.

Collapse this tableExpand this table

Filename Size
SDKServiceSample.cpp 8KB
VCServiceSample.cpp 3KB

Invoking OLE DB Services, Such As the OLE DB Cursor Engine

To use such OLE DB services as the Cursor Engine, refer to the
Data Access SDK documentation or the Microsoft Platform SDK documentation on
the Microsoft Developer Network CD. Specifically, look up “OLE DB Services.” To
use OLE DB services, you must use IDataInitialize or IDBPromptInitialize.
Following is the sample code from the OleDbOrc sample:

Sample Code

// The Init Prompt
InitProperties0.dwPropertyID = DBPROP_INIT_PROMPT;
InitProperties0.vValue.vt = VT_I2;
InitProperties0.vValue.iVal = DBPROMPT_NOPROMPT;
// Data source string.
InitProperties1.dwPropertyID = DBPROP_INIT_DATASOURCE;
InitProperties1.colid = DB_NULLID;
InitProperties1.vValue.vt = VT_BSTR;
InitProperties1.vValue.bstrVal =  SysAllocString(OLESTR("dseoracle"));
// User ID.
InitProperties2.dwPropertyID = DBPROP_AUTH_USERID;
InitProperties2.vValue.vt = VT_BSTR;
InitProperties2.vValue.bstrVal = SysAllocString(OLESTR("demo"));
// Password.
InitProperties3.dwPropertyID = DBPROP_AUTH_PASSWORD;

InitProperties3.vValue.vt = VT_BSTR;
InitProperties3.vValue.bstrVal = SysAllocString(OLESTR("demo"));
// Load the service components.
InitProperties4.dwPropertyID = DBPROP_INIT_OLEDBSERVICES;
InitProperties4.vValue.vt = VT_I4;
InitProperties4.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.

...

if (FAILED(hr = CoCreateInstance(CLSID_MSDAINITIALIZE, NULL,
                CLSCTX_INPROC_SERVER, IID_IDataInitialize,
                (void**)&pDataInit)))
   RETURN(hr)
// Creating the IDBInitialize.
if(FAILED(hr = CLSIDFromProgID(wszProvider, &clsid)))
   RETURN(hr)
if(FAILED(hr = pDataInit->CreateDBInstance(clsid, NULL,
          CLSCTX_INPROC_SERVER, NULL, IID_IDBInitialize, (IUnknown**)
          &pDataSourceIDBInitialize)))
   RETURN(hr)

// Setting the initialization properties.
if(FAILED(hr = pDataSourceIDBInitialize->QueryInterface(IID_IDBProperties,
               (void**)&pProperties)))
   RETURN(hr)
if(FAILED(hr = pProperties->SetProperties(1,&rgInitPropSet)))
   RETURN(hr)
if (FAILED(hr = pDataSourceIDBInitialize->Initialize( )))
   RETURN(hr)
				

Notice the setting of DBPROP_INIT_OLEDBSERVICES. If you are using
the Visual C++ 6.0 ATL OLE DB Consumer templates, you can use the
OpenWithServiceComponents() function. For example:

CDataSource ds;
ds.OpenWithServiceComponents("MSDAORA", propset);
				

Once the datasource is opened using the service components, any rowsets
created with ICommand::Execute() use the cursor engine if the provider doesn’t
provide the necessary functionality (scrolling and updating for
example).

NOTE: If the OLE DB consumer asks for ICommandText and calls Execute,
the services will not be used. You must use QueryInterface() for ICommand and
then query for ICommandText from that pointer.

For additional
information about this, please see the following article in the Microsoft
Knowledge Base:

255996

(http://support.microsoft.com/kb/255996/EN-US/
)

FIX: OLE DB Services Are Not Loaded When Execute() Is Called from ICommandText

Article ID: 223333 – Last Review: December 27, 2013 – Revision: 5.0


Applies to
  • Microsoft Data Access Components 2.1
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7
kbdownload kbdatabase kbfile kbhowto kboracle kbprovider KB223333

More here:
OleDbOrc.exe: Using the OLE DB Cursor Engine Service to Provide Updatability for OLE DB Providers

PRB: Retrieving Properties with OLE DB May Cause Memory Leak

Whenever an OLE DB consumer application retrieves properties from the provider, it is the responsibility of the consumer application to free the memory associated with the property structures that the provider returns.

In some cases, however, freeing the property structures alone, as described in the OLE DB documentation, is not sufficient. Retrieving and freeing the properties will cause a memory leak in this case.

The DBPROPSET structures returned to the client by the provider contain a pointer to an array of DBPROP structures. The DBPROP structures have a VARIANT member called vValue. Because the vValue member could contain a pointer to a BSTR or other allocated memory on output, the vValue member should be cleared by the consumer application by calling the VariantClear function. The OLE DB documentation does not specify this.
This behavior is by design.
The following OLE DB functions return property information to the consumer:

  • IDBProperties::GetProperties
  • IRowsetIndex::GetIndexInfo
  • ICommandProperties::GetProperties
  • IRowsetInfo::GetProperties
  • ISessionProperties::GetProperties

Steps to Reproduce Behavior

The following sample code demonstrates the code that will leak memory:

#include

#include


#include 
#define DBINITCONSTANTS
#include 

int main(int argc, TCHAR * argv[])

	IDataInitialize*	pIDataInitialize = NULL;
	IDBInitialize*		pIDBInitialize = NULL;
	IDBProperties*		pIDBProperties = NULL;

	int					iLoopMax = 10000;
	int					iLoop;
	UINT				iSet;

	DBPROPSET*			pPropsets = NULL;
	unsigned long		cPropertyIDSets = 0 ;
	unsigned long		cPropertySets = 0 ;
	DBPROPIDSET         rgPropertyIDSets1;

	HRESULT hr;
	//If needed, change the connection string here.
	OLECHAR* wszInitString = L"Provider=SQLOLEDB.1;User ID=sa;Initial Catalog=pubs;Data Source=(local);";

	hr = CoInitialize(NULL);

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

	hr = pIDataInitialize->GetDataSource(NULL, CLSCTX_INPROC_SERVER, wszInitString,
		IID_IDBInitialize, ( IUnknown ** ) & pIDBInitialize );

	hr = pIDBInitialize->Initialize();

	hr = pIDBInitialize->QueryInterface(IID_IDBProperties, (void**) &pIDBProperties);

	rgPropertyIDSets0.rgPropertyIDs		= NULL ;
	rgPropertyIDSets0.cPropertyIDs		= 0 ;
	rgPropertyIDSets0.guidPropertySet		= DBPROPSET_DATASOURCE;

	for (iLoop = 0; iLoop < iLoopMax; iLoop++)

		hr = pIDBProperties->GetProperties	( cPropertyIDSets,
												rgPropertyIDSets,
												&cPropertySets,
												&pPropsets) ;

		for (iSet = 0; iSet < cPropertySets;  iSet++ )

			DBPROP *  pr = pPropsetsiSet.rgProperties; 

			//NOTE :Uncomment the following lines to remove the memory leak
			//int iProp;
			//for (iProp = 0; iProp < pPropsetsiSet.cProperties;iProp++)
			//
			//	VariantClear( &(priProp.vValue) );
			//

			CoTaskMemFree(pr);
		}
		CoTaskMemFree(pPropsets);
		Sleep(1);
	}

	hr = pIDBInitialize->Uninitialize();

	if (pIDBProperties)

		pIDBProperties->Release();

	if (pIDBInitialize)

		pIDBInitialize->Release();

	if (pIDataInitialize)

		pIDataInitialize->Release();

	return 0 ;
}
				

To free the memory correctly, uncomment the loop in the code above to free each individual VARIANT member before freeing the DBPROP array.

Article ID: 293349 – Last Review: December 27, 2013 – Revision: 3.0


Applies to
  • Microsoft Data Access Components 2.7
kbdatabase kbprb KB293349

Original post:
PRB: Retrieving Properties with OLE DB May Cause Memory Leak

PRB: "Errors Occurred" Error When Calling Stored Procedure with More than a SELECT Statement

#include 

class CTestAccessor

public:
	LONG m_RETURNVALUE;

BEGIN_PARAM_MAP(CTestAccessor)
	SET_PARAM_TYPE(DBPARAMIO_OUTPUT)
	COLUMN_ENTRY(1, m_RETURNVALUE)
END_PARAM_MAP()

DEFINE_COMMAND(CTestAccessor, _T(" ? = CALL dbo.sp_Test"))

};

class CTestCmd : public CCommand >

public:
	HRESULT Open()

		HRESULT		hr;

		hr = OpenDataSource();
		if (FAILED(hr))
			return hr;

		return OpenRowset();

	HRESULT OpenDataSource()

		HRESULT		hr;
		CDataSource db;
		CDBPropSet	dbinit(DBPROPSET_DBINIT);

		dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("sa"));
		dbinit.AddProperty(DBPROP_INIT_CATALOG, OLESTR("pubs"));
		//change the name of SQL server to fit your environment
                dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR("localhost"));
                dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);
		dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);

		//Use this line if you want to use a forward only, read only client side cursor
		hr = db.Open(_T("SQLOLEDB.1"), &dbinit);

		//Use this line if you want to use an updateable client side cursor
		//hr = db.OpenWithServiceComponents(_T("SQLOLEDB.1"), &dbinit); 

		if (FAILED(hr))
			return hr;

		return m_session.Open(db);

	HRESULT OpenRowset()

		// Set properties for open
		CDBPropSet	propset(DBPROPSET_ROWSET);

		//Remove the following properties to prevent the error with a forward only, read only client side cursor
		//Set them if you want an updateable client side cursor
		propset.AddProperty(DBPROP_IRowsetChange, true);
		propset.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_CHANGE
	CSession	m_session;
};

int main(int argc, char* argv[])

	CoInitialize(NULL);

	CTestCmd rs;
	HRESULT hr=rs.Open();
	if (FAILED(hr))
            AtlTraceErrorRecords();

	rs.Close();

	return 0;

See more here:
PRB: "Errors Occurred" Error When Calling Stored Procedure with More than a SELECT Statement

Page 22 of 693« First...10...2021222324...304050...Last »

Recent Comments

    Archives

    Categories