bala.narne
August 18th, 2000, 07:32 AM
Hi,
I am writing a ATL com component which will be used by other
computer in network that is a DCOM component.
The requirement is to create a .mdb file programmatically using ADOX.
The requirement is that I should not create a DSN statically.
The code is as follows in FinalConstruct function:
member variables:
------------------------
ADODB::_ConnectionPtr m_pconnection;
_CatalogPtr m_pCatalog;
----------------------
m_pCatalog = NULL;
_TablePtr m_pTable = NULL;
_variant_t var;
//Set ActiveConnection of Catalog to this string
_bstr_t strcnn("Provider=Microsoft.JET.OLEDB.4.0;"
"Data source = c:\\com\\AdoServer4\\new.mdb");
try
{
hr = m_pCatalog.CreateInstance(__uuidof (Catalog));
// Create .mdb file dynamically
var = m_pCatalog->Create(strcnn);
//Open the catalog
m_pCatalog->PutActiveConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;" \
"data source=c:\\com\\AdoServer4\\new.mdb;");
hr = m_pTable.CreateInstance(__uuidof(Table));
}
The problem is when I register component in other computer and execute
client program then I will get error -
Invalid Path c:\\com\\AdoServer4\\new.mdb.
Thus failing CoCreateInstanceEx.
How do I solve this problem?
I am writing a ATL com component which will be used by other
computer in network that is a DCOM component.
The requirement is to create a .mdb file programmatically using ADOX.
The requirement is that I should not create a DSN statically.
The code is as follows in FinalConstruct function:
member variables:
------------------------
ADODB::_ConnectionPtr m_pconnection;
_CatalogPtr m_pCatalog;
----------------------
m_pCatalog = NULL;
_TablePtr m_pTable = NULL;
_variant_t var;
//Set ActiveConnection of Catalog to this string
_bstr_t strcnn("Provider=Microsoft.JET.OLEDB.4.0;"
"Data source = c:\\com\\AdoServer4\\new.mdb");
try
{
hr = m_pCatalog.CreateInstance(__uuidof (Catalog));
// Create .mdb file dynamically
var = m_pCatalog->Create(strcnn);
//Open the catalog
m_pCatalog->PutActiveConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;" \
"data source=c:\\com\\AdoServer4\\new.mdb;");
hr = m_pTable.CreateInstance(__uuidof(Table));
}
The problem is when I register component in other computer and execute
client program then I will get error -
Invalid Path c:\\com\\AdoServer4\\new.mdb.
Thus failing CoCreateInstanceEx.
How do I solve this problem?