INF: Common SQL-DMO C/C++ Programming Issues
ID: Q134819
|
The information in this article applies to:
-
Microsoft SQL Server version 6.0
SUMMARY
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.
MORE INFORMATION- 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");
Additional query words:
sql6 programming ole 32-bit
Keywords : kbprg SSrvDMO SSrvErr_Log SSrvProg
Version : 6.0
Platform : WINDOWS
Issue type :
|