艰苦的过程:在evc中使用ADOCE的前期准备(从原来的blog转过来的)

作者:liguisen

bloghttp://blog.csdn.net/liguisen/

 

作者:zuilang

 

目标:evc4下在standardsdk emulator或者ppc2003用adoce3.0(或者3.1)访问sdf数据库

问题:使用evc4第一个碰到的问题就是,ADOCE3.1在哪里?怎么安装ADOCE3.1?
先来看一段SQL SERVER CE2.0的Readme:(节选)

2.3.1  Setup for eMbedded Visual Tools
1.Before you install SQL Server CE for use with the eMbedded Visual Tools development environment, you must: Install Microsoft eMbedded Visual Tools 3.0 and at least one of the following software development kits: Microsoft Windows Powered Pocket PC 2002, Pocket PC, or Handheld PC 2000.
2.Upgrade to Microsoft ActiveSync® 3.5 or later.
3.Verify that you have Administrator access on the target system and that the Administrators group has change permission on the installation directory.
Install Development Tools on the computer that you will use to develop your SQL Server CE-based applications, and install Server Tools on the computer that you will use as the server running Microsoft Internet Information Services (IIS). SQL Server CE Setup prompts you for a Development Tools or a Server Tools installation. If the development computer and the computer running IIS are the same, you can install both Development Tools and Server Tools.

1.A Development Tools installation first installs the Microsoft ActiveX® Data Objects for Windows CE (ADOCE) 3.1 components and then the SQL Server CE components. The following table shows the products and where they are installed by default.
Product                      Folder
ADOCE 3.1              C:/Windows CE Tools/Dataaccess31
SQL Server CE        C:/Program Files/Microsoft SQL Server CE 2.0
Server Tools Setup (a self-extracting executable, which can be used to configure the IIS computer)    C:/Program Files/Microsoft SQL Server CE 2.0/Redist

2.A Server Tools installation, by default, first installs Microsoft Data Access Components (MDAC) 2.6, and then the SQL Server CE components in C:/Program Files/Microsoft SQL Server CE 2.0/Server on the computer running IIS. If a later version of MDAC is already installed on the computer, the Server Tools installation does not install MDAC 2.6. Server Tools requires Microsoft Internet Explorer 5.01.

To install SQL Server CE on a Pocket PC-based, Pocket PC 2002-based, or Handheld PC 2000-based device, use either the eMbedded Visual Basic procedure or the manual procedure described in SQL Server CE Books Online. The Include and Lib files for SQL Server CE are located in the Lib and Inc subdirectories of the SQL Server CE installation directory. The Include and Lib files for OLE DB for SQL Server CE are located in the Include and Lib subdirectories of the Dataaccess31 folder. Use the Lib file that matches the processor and platform for which you are compiling.

Note  Using ADOCE through Microsoft eMbedded Visual C++® is not a supported means for accessing SQL Server CE.

装了很多次了,都没有安装ADOCE3.1(暂时的证据是整个硬盘都找不到Dataaccess31文件夹),于是我到微软上下载了这两个东西:

(1)ActiveX Data Objects for the Windows CE operating system (ADOCE) 3.1
文件名:adocepbzip.exe
地址:http://www.microsoft.com/downloads/details.aspx?FamilyID=929bb147-281c-4d6e-a727-67271075fadb&DisplayLang=en

(2)ActiveX Data Objects for the WindowsCE operating system (ADOCE) 3.1 for Windows 3.0 SDKs
文件名:adocesdkzip.exe
地址:http://www.microsoft.com/downloads/details.aspx?FamilyID=929bb147-281c-4d6e-a727-67271075fadb&DisplayLang=en

安装第一个时提示要先装PB,我没装,放弃,装第二个时提示要先装至少一个windows ce platform sdk,我已经有了standardsdk emulator还有ppc和sp(都是2003),怎么还提示我这个?又放弃。后来看readme发现:

Requirements

Windows® CE Data Access 3.1 requires the new release of Microsoft® Embedded Visual Tools. Prior to installing this SDK add-on, you must have previously installed any or all of the following Windows CE SDKs:

  • Microsoft SDK for Windows CE, Handheld PC Professional Edition 3.0
  • Microsoft SDK for Windows CE, Palm-size PC Edition 1.2
  • Microsoft Windows Platform SDK for Pocket PC

明白!

且看网友怎么说:

网友jiess(杰西)说:
装了sqlce2.0,在PC机上有adoce31,拷贝到DEVICE上,运行时,用dllregister注册一下就行了.

网友jacky_emdoor(浪子)说:
其实只需要(下载下来的安装文件里面的)/adocepb/setup/Data Access 3.1/Program Files/DataAccess31/DEVICE/ARM/SA1100/CE/RETAIL下的DLL文件拷贝到WINCE下/WINDOWS下,并且注册必要的组件,再运行你的数据库软件就可以了。

疑问:“装了sqlce2.0,在PC机上有adoce31”,我的怎么没有?/Windows CE Tools目录下没有dataaccess的目录。于是我按照jacky_emdoor(浪子)的说法去做,的确是可以注册的。

另外:
有网友说:
在evc里使用
namespace MSADOCE
{
#include <adoce31.h>
}
我编译时出现fatal error C1083: Cannot open include file: 'adoce31.h': No such file or directory
那么,如何获得这个adoce31.h?(后面会说到)

vvv_for_ever (vvvvv) 说:

1)生成adoce31.h头文件
2)用dllregster.exe注册了所有有关adoce31的dll文件
3)已经可以正确地生成connection和recordset
但是出现了如下问题:
1)当recordset调用put_ActiveConnection的时候发生如下错误:datatype misalignment
2)使用VOConnection和VORecordset时,也出现了一样的问题.
3)我将VOConnection和VORecordset中对ADO30.h的引用都改成了ado31.h,是不是这样就能完成Connection和VORecordset到ado31的过渡了?

不明白他是怎么生成adoce31.h头文件的?(后面会说到)

回过头来看看Readme,你会发现,上面说的都是evt(evc3)环境下的安装,呜呼!
于是,我在已安装evc4的情况下安装evt,结果依然。并且这个时候我发现,vc#.net的移动设备开发被破坏了,根本不能建立这样的工程。没办法,我只好都卸掉evc4和evt,然后重装evt。发现原来evt自带ppc2002。装好后,发现已经有了这样一个文件夹:/Windows CE Tools/wce300/Pocket PC 2002/dataaccess31,实在不明白,dataaccess31不是在安装SQL SERVER CE的时候才安装的吗?(而且我在安装SQL SERVER CE2.0时发现它的安装过程的确有复制adoce的东西)另外,在/Windows CE Tools/wce300/Pocket PC 2002/include里面还发现了ADOCE30这些头文件,3.0和3.1都有了???不解!

下面来看看如何获得ADOCE31.h文件,其实很简单:
先在下载下来的ADOCE3.1的安装文件里面找到adoce31.idl、adocec31.idl这两个文件,然后在命令行下执行 midl adoce31.idl就会生成ADOCE31.h了。同时,你还需要执行midl adocec31.idl来获得adocec31.h。

顺便来看一个常见的问题:

大哥,再问下! 我装好后里面就有一个Configure Connectivity Support in IIS  我再什么地方加数据库 设计表啊?是不是我装得不对 我都装了3遍了啊 !

回答:安装正确!
创建数据库的两种方法:
1.用sql语句创建
2.还可以通过isqlw20.exe来可视化创建(关于这个,请看下面)

来看看SQL Server Books Online里面的Installing SQL Server CE on a Device Using eMbedded Visual Tools

Manual Installation Process
You can manually install SQL Server CE and your eMbedded Visual Tools application on a Windows CE-based device by copying and registering all the required files. Use the following information to determine which files the application requires. Select the files appropriate for the processor type of the Windows CE-based device. To determine the processor type of the device, see the device documentation.

Application Files
On Pocket PCs, you can copy the application executable to the /Windows/Start Menu folder, and then run it from the Start menu on the device. The application executable file is located in the project tree that you create:

Microsoft eMbedded Visual Basic creates the executable file directly in the project subdirectory.
Microsoft eMbedded Visual C++® creates a separate subdirectory for each platform processor type that you want it to build. For example, MIPS processor application executables are created in /projectname/MIPSRel for the release version and /projectname/MIPSDbg for the debug version.

SQL Server CE Files
Copy the SQL Server CE files to the /Windows directory of the Windows CE-based device. These files are located in /Program Files/Microsoft SQL Server CE 2.0/Device/processor family/processor type by default. For more information about file locations and descriptions, see Installing SQL Server CE with eMbedded Visual Tools.

File                                            Requirement
Ssce20.dll                                  Required. Must be registered.
Ssceca20.dll                              Required for replication and remote data access (RDA). Must be registered.
Ssceerror20en.dll                       Optional for error messages used during development.
Isqlw20.exe                               Optional for SQL Server CE Query Analyzer.

ADOCE and OLE DB Files
Copy the SQL Server CE files to the /Windows directory on the Windows CE-based device. These files are located by default in /Windows CE Tools/dataaccess31/Windows CE OS version/processor type.

File                          Requirement
Msdaeren.dll           Optional for error messages. Msdaeren.dll is the English version of the Microsoft ActiveX  Data  Objects for Windows CE (ADOCE) error DLL and works on devices of all languages. For localized ADOCE error messages, substitute the Msdaerxx.dll that corresponds to the language setting of the device.
Adoce31.dll            Required. Must be registered.
Adoceoledb31.dll   Required.
Adoxce31.dll          Required for ADOXCE. Must be registered.

Registering the SQL Server CE Application on the Device
Use DllRegister.exe to register the DLLs that require registration. DllRegister.exe registers all the SQL Server CE, ADOCE, and OLE DB CE components on the device and warns if optional components are missing from the device. DllRegister.exe is located by default in /Program Files/Microsoft SQL Server CE 2.0/Device/processor family/processor type.

To register the SQL Server CE application

Select the appropriate version of DllRegister.exe based on the processor type of the device.
Copy DllRegister.exe from the development system to the Windows CE-based device, and then run the executable. On Pocket PCs, you can copy DllRegister.exe to the /Windows/Start menu folder, and then run it from the Start menu on the device.

Alternately, you can register the DLLs individually by using Regsvrce.exe from the Windows CE SDK or by calling the DllRegisterServer function in each DLL.

这是手工安装的过程,基本上是把相关的dll放到设备(或模拟器)当中使用DllRegister.exe注册,注意,当中有些路径可能和文档所说的有点出入,我的就不一样,例如dataaccess31的路径。还有一个要注意的是(以x86为例),在/Device/X86目录下有两个文件夹/I486和/Emulation,里面都有相同的dll,在模拟器当中应该使用/I486文件夹的(奇怪,为什么不是Emulation?),在实际设备当中没有测试过。

在ppc中,也许你还可以复制/Microsoft Visual Studio .NET 2003/CompactFrameworkSDK/v1.0.5000/Windows CE/wce300/x86下面的文件,然后在ppc中单击安装,同样会得到isqlw20.exe来可视化创建数据库。

暂时得到的结论是:

1,evt下使用ADOCE比较方便,安装ppc2002时就会安装ADOCE3.0,同时也会安装ADOCE3.1,不过,也许这些会在安装SQL SERVER CE才安装。
2,evc4下也是可以使用ADOCE3.1的,已有网友成功。估计是不需要在pc机上安装的,有网友说只需要找到相关文件(例如可以在我上面说的下载的文件里面找到)在pc机上设置好路径就可以开发,至于在设备中,可以用dllregister注册。(这个未经证实:))
3,看看吧:Note  Using ADOCE through Microsoft eMbedded Visual C++® is not a supported means for accessing SQL Server CE.看来,真的要考虑.net了。
4,绕弯路的最大原因是没有看文档,或者看了也不仔细,或者英文水平有限,不能很好的理解。其实选择微软的东西开发有一个很大的好处就是:文档齐全!

你可能感兴趣的:(艰苦的过程:在evc中使用ADOCE的前期准备(从原来的blog转过来的))