艱苦的過程:在evc中使用ADOCE的前期準備(從原來的blog轉過來的)

來源:互聯網
上載者:User

作者:liguisen

blog:http://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,繞彎路的最大原因是沒有看文檔,或者看了也不仔細,或者英文水平有限,不能很好的理解。其實選擇微軟的東西開發有一個很大的好處就是:文檔齊全!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.