This article provides information regarding some of the more common errors
you may encounter when you attempt to develop a Microsoft SQL Server
version 6.0 distributed management objects (SQL-DMO) application.
- Problem:
OUT OF MEMORY error returned from CoCreateInstance().
Cause:
You can encounter this error in a couple of ways. The first is an actual
out of memory situation. The second and more common is caused by a
missing DLL or invalid SQL-DMO environment.
Resolution:
Make sure you do not have a physical memory error. Also ensure that the
SQL-DMO environment was properly installed. You must have the
SQLSVC32.DLL and the SQLOLE32.DLL files available and in the
applications search path. You also need to have used the SQLOLE.REG file
to properly register the SQL-DMO objects.
- Problem:
Ordinal 164 could not be located.
Cause:
An attempt is made to use a SQL-DMO application without the SQL
Server version 6.0 DBLIBRARY DLL file.
Resolution:
Install the SQL Server version 6.0 version of the DBLIBRARY, such as
NTWDBLIB.DLL.
- Problem:
if(hResult) does not evaluate as expected
Cause:
S_OK is equal to zero, so statements such as the following can cause
unexpected behavior:
if(S_OK & hResult)
-OR-
if(hResult)
Resolution:
Since S_OK is equal to zero, it does not evaluate to a non-zero value,
so it evaluates to false and takes the else branch.
Change statements to look like the following:
if(S_OK == hResult)
Or, use the SUCCEED macro to check the status.
- Problem:
CoInitialize() returns S_FALSE in an MFC application.
Cause:
By default, if you build an MFC project enabled for OLE support, the
AfxInitOle() function is called in the CWinApp derived class.
Resolution:
Continue to call the CoInitialize function. This will always ensure the
initialization has taken place. For instance if the CoUnInitialize()
function is invoked and you want to do another CoCreateInstance(), then
you must call the CoInitialize() the second time to reinitialize.
- Problem:
Error C2039: 'xxx' : is not a member of 'IASQLOLEServer'
Cause:
The specific code line has attempted to directly access an object
property.
Resolution:
Use the Set and Get methods to access the data.
pSQLServer->SetApplicationName("SQL_DMO Test");
pSQLServer->SetHostName("Sample");