C2872: 'IServiceProvider' : Help.!!!!!!!!

G

gerry.brennan

I have a generic c++ class database which interfaces to a database via
odbc, called database.cpp/database.h

When I am writing to the database I Open a CRecordset object and
populate the table in teh database.

I #include <afxdb.h> in the cpp file.


ALSO, it will be possible to pass in a CRecordset into the database
class.

In database.h I write create the prototype.
int getStockData(CRecordset* gData,String* sqlString);

The compiler complains that it does not know the type CRecordset.

When I include #include <afxdb.h>

I get "error C2872: 'IServiceProvider' : ambiguous symbol"

Can anyone Help.
 
B

Bruno van Dooren

Hi Gerry,

I have a generic c++ class database which interfaces to a database via
odbc, called database.cpp/database.h

When I am writing to the database I Open a CRecordset object and
populate the table in teh database.

I #include <afxdb.h> in the cpp file.
ALSO, it will be possible to pass in a CRecordset into the database
class.

In database.h I write create the prototype.
int getStockData(CRecordset* gData,String* sqlString);

The compiler complains that it does not know the type CRecordset.

do you include it before or after you include your database.h?
if you don't include it in you database.h, you should include it in the cpp
files before your database.h
When I include #include <afxdb.h>

I get "error C2872: 'IServiceProvider' : ambiguous symbol"
IServiceProvider exists as an Ole DB interface and a .NET interface. are you
trying to mix them somehow?


Kind regards,
Bruno.
 
G

gerry.brennan

Hi Bruno,
Here is the top of the database.cpp file.

#using <mscorlib.dll>
#include "StdAfx.h"
#include <afxdb.h>
#include "database.h"
using namespace System;




Here is the top of the database.h file.

#pragma once

#include <afxdb.h>
#include "customer.h"
#include "Stock.h"

One other point if I remove all references to CRecordset in the header.

I am still getting the same error.

c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\ServProv.h(93): error C2872:
'IServiceProvider' : ambiguous symbol

Gerry.
 
B

Bruno van Dooren

Hi,
#using <mscorlib.dll>
#include "StdAfx.h"
#include <afxdb.h>
#include "database.h"
using namespace System;

you are #using <mscorlib.dll> and using namespace System.
IServiceProvider is an interface defined in the .NET framework System
namespace.
This name conflicts with the IServiceProvider that is declared in afxdb.h,
although
there are a number of different IServiceProvider definitions.

i have compiled a C++/cli console application with these includes without a
problem.

could you post a small project that reproduces the problem so that i can try
to compile it?

kind regards,
Bruno.
 
G

gerry.brennan

Bruno,

I have sent you a ReadyToCompile simple example ... to your hotmail...

Gerry.
 
B

Bruno van Dooren

Hi Gerry,

i removed <afxdb.h> from your database.h and .cpp file, and added it to
StdAfx.h instead.
that solves the IServiceProvider problem.

a compile of Form1.cpp then resulted in an error because Form1.cpp contained
the following line:
database a = new database;

changing that to
database *a = new database();

solved that. after that the project builds and runs without a problem.

kind regards,
Bruno.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top