sql >> Database teknologi >  >> RDS >> Sqlserver

Hvordan implementerer jeg SQL Server Compact Edition 4.0?

jeg har lavet løsningen.

SQL Server Compact Edition består af 7 dll'er:

  • sqlceme40.dll Det udokumenterede, oprindelige, flade API-bibliotek (.net System.Data.SqlServerCe.dll assembly er en indpakning omkring denne dll)
  • sqlceca40.dll En COM dll, der implementerer Engine , Replication , Error og et par andre COM-objekter
  • sqlceoledb40.dll En COM dll, der implementerer en OLEdb-udbyder til SSCE (tillader brugen af ​​ADO)
  • sqlcese40.dll ukendt
  • sqlceqp40.dll ukendt
  • sqlcecompact40.dll ukendt
  • sqlceer40en.dll ukendt

Problemet med blot at prøve at sende disse dll'er er, at to af dem er COM genstande. COM-objekt-dll'er skal registreres , f.eks.:

>regsvr32 sqlceca40.dll
>regsvr32 sqlceoledb40.dll

Problemet er, at registrering af et COM-objekt kræver administrativ privilegier (brug af en global løsning til at løse et lokalt problem ). Det betyder, at dine brugere ville

  • skal installere din ansøgning (som du ikke ønsker at gøre)
  • kræver, at dine brugere har administrative tilladelser (hvilket du ikke ønsker)

Heldigvis, fra 2001 med Windows XP, løste Microsoft dette FÆLLES problem:Registrering- Gratis COM .

Først skal du erklære, at din ansøgning har en "afhængighed" på SQL Server Compact Edition 4.0. Det gør du ved at oprette et montagemanifest:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
    <assemblyIdentity 
        version="1.0.0.0"
        processorArchitecture="X86"
        name="client"
        type="win32"
    /> 

    <description>Hyperion Pro</description> 

    <!-- We have a dependancy on SQL Server CE 4.0 -->
    <dependency>
        <dependentAssembly>
            <assemblyIdentity
                type="win32"
                name="Microsoft.SQLSERVER.CE.4.0"
                version="4.0.0.0" processorArchitecture="x86"
            />
        </dependentAssembly>
    </dependency>
    <!-- We are high-dpi aware on Windows Vista -->
    <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
        <asmv3:windowsSettings
            xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
            <dpiAware>true</dpiAware>
        </asmv3:windowsSettings>
    </asmv3:application>

    <!-- We were designed and tested on Windows 7 -->
    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
        <application>
            <!--The ID below indicates application support for Windows 7 -->
            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
            <!--The ID below indicates application support for Windows Vista -->
            <!--supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/-->
        </application>
    </compatibility>

    <!-- Disable file and registry virtualization -->
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
        <security>
            <requestedPrivileges>
                <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
            </requestedPrivileges>
        </security>
    </trustInfo>
</assembly>

Du kan placere denne fil ved siden af din eksekverbare (som Hyperion.exe.manifest ), eller du kan indbygge det i din applikation som en RT_MANIFEST ressource.

Bemærk, at vi har en afhængighed af en assembly kaldet Microsoft.SQLSERVER.CE.4.0 . Vi opretter først denne samling ved at oprette en mappe kaldet:

Når du implementerer dit program, vil du placere alle 7 dll'er, der omfatter denne "samling" ind i denne Microsoft.SQLSERVER.CE.4.0 undermappe sammen med en speciel .manifest fil:

📁C:\
╰──📁Users
   ╰──📁Ian
      ╰──📁AppData
         ╰──📁Local
            ╰──📁Hyperion Pro
               ├──📄Hyperion.exe
               ├──📄Hyperion.exe.manifest
               ╰──📁Microsoft.SQLSERVER.CE.4.0
                  ├──📄sqlceme40.dll
                  ├──📄sqlceca40.dll
                  ├──📄sqlceoledb40.dll
                  ├──📄sqlcese40.dll
                  ├──📄sqlceqp40.dll
                  ├──📄sqlcecompact40.dll
                  ├──📄sqlceer40en.dll
                  ╰──📄Microsoft.SQLSERVER.CE.4.0.manifest

Med andre ord indeholder applikationsmappen din applikation og Microsoft.SQLSERVER.CE.4.0 mappe:

 Directory of C:\Users\Ian\AppData\Local\Hyperion Pro

05/29/2012  09:23 AM         1,899,008 Hyperion.exe
05/28/2012  01:46 PM             1,587 Hyperion.exe.manifest
05/29/2012  09:27 AM    <DIR>          Microsoft.SQLSERVER.CE.4.0
           2 File(s)      1,900,675 bytes
           1 Dir(s)  20,851,503,104 bytes free

Den næste del af din opgave er at definere Microsoft.SQLSERVER.CE.4.0.manifest fil. Registreringsfri COM tillader en manifestfil at erklære alle COM-objekter og deres clsid'er. Dette krævede meget reverse engineering. Men montagemanifestet for SQL Server Compact Edition 4.0 er:

Microsoft.SQLSERVER.CE.4.0.manifest :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

<assemblyIdentity 
       type="win32"
       name="Microsoft.SQLSERVER.CE.4.0"
       processorArchitecture="x86"
       version="4.0.0.0" />

<!-- OLEDB Provider -->
<file name = "sqlceoledb40.dll">
    <comClass
            description = "Microsoft SQL Server Compact OLE DB Provider for Windows"
            clsid="{2006C53A-C915-41EA-BAA9-9EAB3A1FBF97}"
            threadingModel = "Both"
            progid = "Microsoft.SQLSERVER.CE.OLEDB.4.0" />
</file>

<!-- Native flat engine library -->
<file name="sqlceme40.dll" />

<!-- Engine and Replication COM object -->
<file name="sqlceca40.dll">
    <comClass description="Active SSCE Engine Object"
            clsid="{68D45319-3702-4837-9F8E-DA6845D82482}"
            threadingModel="Both"
            progid="SSCE.Engine.4.0" />
    <comClass description="SSCE Error Object"
            clsid="{36228F21-B5C7-4054-8DC2-47D3E236E8B5}"
            threadingModel="Both"
            progid="SSCE.Error.4.0" />
    <comClass description="SSCE Param Object"
            clsid="{0B3A7B75-A9B0-4580-9AA5-1A7DA47AD1CB}"
            threadingModel="Both"
            progid="SSCE.Param.4.0" />
    <comClass description="Active SSCE Replication Object"
            clsid="{11D5B2D4-26A4-44F5-A48B-0FAC3A919ED8}"
            threadingModel="Both"
            progid="SSCE.Replication.4.0" />
    <comClass description="Active SSCE remote data access Object"
            clsid="{58BC9AD6-BF11-40B3-9AB1-E3F2ED784C08}"
            threadingModel="Both"
            progid="SSCE.RemoteDataAccess.4.0" />

    <typelib tlbid="{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}"
            version="4.0" 
            helpdir=""/>
</file>

<comInterfaceExternalProxyStub 
    name="ISSCEEngine"
    iid="{10EC3E45-0870-4D7B-9A2D-F4F81B6B7FA2}"
    proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
    baseInterface="{00000000-0000-0000-C000-000000000046}"
    tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" />

<comInterfaceExternalProxyStub 
    name="ISSCEError"
    iid="{31155A3B-871D-407F-9F73-DEBFAC7EFBE3}"
    proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
    baseInterface="{00000000-0000-0000-C000-000000000046}"
    tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" />

<comInterfaceExternalProxyStub 
    name="ISSCERDA"
    iid="{4F04F79D-1FF1-4DCD-802B-3D51B9356C14}"
    proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
    baseInterface="{00000000-0000-0000-C000-000000000046}"
    tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" />

<comInterfaceExternalProxyStub 
    name="ISSCEParams"
    iid="{A78AFF90-049C-41EC-B1D8-665968AAC4A6}"
    proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
    baseInterface="{00000000-0000-0000-C000-000000000046}"
    tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" />

<comInterfaceExternalProxyStub 
    name="ISSCEParam"
    iid="{A9876C60-2667-44E5-89DB-E9A46ED392C0}"
    proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
    baseInterface="{00000000-0000-0000-C000-000000000046}"
    tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" />

<comInterfaceExternalProxyStub 
    name="ISSCEErrors"
    iid="{C40143CA-E9F9-4FF4-B8B4-CC02C064FC1B}"
    proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
    baseInterface="{00000000-0000-0000-C000-000000000046}"
    tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" />

<comInterfaceExternalProxyStub 
    name="ISSCEMerge"
    iid="{C6EB397F-D585-428D-A4F4-454A1842CB47}"
    proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
    baseInterface="{00000000-0000-0000-C000-000000000046}"
    tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" />

<file name="sqlceqp40.dll" />
<file name="sqlcese40.dll" />
<file name="sqlcecompact40.dll" />
<file name="sqlceer40EN.dll" />

</assembly>

Det sidste er, at vi på samme måde er afhængige af en samling kaldet Microsoft.SQLSERVER.CE.4.0 , SQL Server Compact Edition 4.0 har igen en afhængighed af en samling kaldet Microsoft.VC90.CRT . Heldigvis leveres din installation af SQLCE med en kopi af denne samling:

📁Microsoft.VC90.CRT
├──📄Microsoft.VC90.CRT.manifest 
╰──📄msvcr90.dll

Dette betyder, at den endelige mappestruktur er:

📁C:\
╰──📁Users
   ╰──📁Ian
      ╰──📁AppData
         ╰──📁Local
            ╰──📁Hyperion Pro
               ├──📄Hyperion.exe
               ├──📄Hyperion.exe.manifest
               ╰──📁Microsoft.SQLSERVER.CE.4.0
                  ├──📄Microsoft.SQLSERVER.CE.4.0.manifest
                  ├──📄sqlceme40.dll
                  ├──📄sqlceca40.dll
                  ├──📄sqlceoledb40.dll
                  ├──📄sqlcese40.dll
                  ├──📄sqlceqp40.dll
                  ├──📄sqlcecompact40.dll
                  ├──📄sqlceer40en.dll
                  ╰──📁Microsoft.VC90.CRT
                     ├──📄Microsoft.VC90.CRT.manifest
                     ╰──📄msvcr90.dll
               


  1. Postgress fejl- bundle installation

  2. ORA-00257:arkiveringsfejl. Tilslut kun internt, indtil det frigøres.

  3. Tomcat-konfiguration ved hjælp af DBCP

  4. Sådan hentes data fra tre tabeller i SQL