Actually, SQL CE database upgrade is briefly discussed in BOL (Book On-Line). And this blog is just to fill the missing link.
Normally, You can create a brand new application to use .NET CF 2.0 & SQL CE 3.0. Then what's the big deal about the SQL CE database upgrade, you might ask. Well,What you actually face in real-life situation is you are .NET CF 1.0 & SQL CE 2.0 application developer. Due to performance issue (SqlCeResultSet Class) or new functionality that only available in SQL CE 3.0, you need to meet the new requirement yet need to maintain the records that already keep in existing SQL CE 2.0 database. You do not want to create a new SQL CE 3.0 database and import back all the records, ain't you? Then, this is where SQL CE database upgrade comes in.
How will one know the database file (*.sdf) is not workable in SQL CE 3.0 ? Simple, open it from MSSQL Management Studio (Sorry, you need full version to run it). If you see this message, clearly you need to upgrade your database.



So now you should have 5 cabinet files(sqlce20.dev.ppc.wce4.armv4.cab, sqlce20.ppc.wce4.armv4.cab, sqlce30.dev.ENU.ppc.wce4.armv4.cab, sqlce30.dev.ppc.wce4.armv4.cab, sqlce30.rep.ppc.wce4.armv4.cab), 3 executable files (upgrade.exe, cmd.exe & shell.exe from Power Toy) and one SQL CE 2.0 database (oldDB.sdf). Install all the 5 cabinet files & click on the cmd.exe to run it. You will be prompt to enter command.
Type something like: upgrade.exe /s oldDB.sdf /d newDB.sdf

If you have missed any cabinet file during installation (eg. you did not install "sqlce30.rep.ppc.wce4.armv4.cab"), you will get this error message:

Connecting to source databaseCreating destination databaseUnable to instantiate SQL CE 3.0 provider
HRESULT: 0x80040154Database upgrade failed
HRESULT: 0x80040154Database upgrade failed
No comments:
Post a Comment