Create a Link to an ODBC Database with MFC DAO

Create a Link to an ODBC Database with MFC DAO

Post by ST » Tue, 04 Dec 2001 17:07:53



I want to create a link to an ODBC Database in an Access97 or 2000 database,
using the MFC DAO Class CDaoTableDef.

It seems that my way it's not the good one.

For example, to create a link to an Excel 8.0 table using the ISAM driver,
the code could be:

CString szConnect = "Excel 8.0;DATABASE=C:\\Excel\\MyTable.xls";

CDaoTableDef td(&MyDatabase);
td.Create("MyLink", 0, "MySheet", szConnect);
td.Append();
td.Close();

That works fine!

How should be the equivalent code to create a link to the same table, using
the ODBC Excel driver ?
What's wrong with the next one (because it's doesn't work) ?

CString szConnect =
"ODBC;DBQ=C:\\Excel\\MyTable.xls;DefaultDir=C:\\Excel;Driver={Microsoft
Excel Driver (*.xls)};DriverId=790;FIL=excel 8.0;FILEDSN=C:\\Program
Files\\Common Files\\ODBC\\Data
Sources\\MyDsn.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;ReadOnly=1
;SafeTransactions=0";

CDaoTableDef td(&MyDatabase);
td.Create("MyLink", 0, "MySheet", szConnect);
td.Append();
td.Close();

Thanks!

 
 
 

Create a Link to an ODBC Database with MFC DAO

Post by Max[M » Thu, 06 Dec 2001 18:28:12


Hello,

You cannot use ODBC to import from, export to external Microsoft Jet or
ISAM database table to your database

This article for your reference,
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q154643

Hope this helps. If you have any questions, please reply to this post.

Regards,
Max
==========================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------


>>Subject: [?] Create a Link to an ODBC Database with MFC DAO
>>Date: Mon, 3 Dec 2001 10:07:53 +0200

>>I want to create a link to an ODBC Database in an Access97 or 2000
database,
>>using the MFC DAO Class CDaoTableDef.

>>It seems that my way it's not the good one.

>>For example, to create a link to an Excel 8.0 table using the ISAM driver,
>>the code could be:

>>CString szConnect = "Excel 8.0;DATABASE=C:\\Excel\\MyTable.xls";

>>CDaoTableDef td(&MyDatabase);
>>td.Create("MyLink", 0, "MySheet", szConnect);
>>td.Append();
>>td.Close();

>>That works fine!

>>How should be the equivalent code to create a link to the same table,
using
>>the ODBC Excel driver ?
>>What's wrong with the next one (because it's doesn't work) ?

>>CString szConnect =
>>"ODBC;DBQ=C:\\Excel\\MyTable.xls;DefaultDir=C:\\Excel;Driver={Microsoft
>>Excel Driver (*.xls)};DriverId=790;FIL=excel 8.0;FILEDSN=C:\\Program
>>Files\\Common Files\\ODBC\\Data
>>Sources\\MyDsn.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;ReadOnly
=1
>>;SafeTransactions=0";

>>CDaoTableDef td(&MyDatabase);
>>td.Create("MyLink", 0, "MySheet", szConnect);
>>td.Append();
>>td.Close();

>>Thanks!