SQL Server CE Database Development with the .NET Compact Framework Copyright ©2003 by Rob Tiffany Originally Published by Apress in 2003
Total Page:16
File Type:pdf, Size:1020Kb
SQL Server CE Database Development- with the .NET Compact Framework ROB TIFFANY APress Media, LLC SQL Server CE Database Development with the .NET Compact Framework Copyright ©2003 by Rob Tiffany Originally published by Apress in 2003 All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN 978-1-59059-119-2 ISBN 978-1-4302-0785-6 (eBook) DOI 10.1007/978-1-4302-0785-6 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Technical Reviewer: Darren Flatt Editorial Board: Dan Appleman, Craig Berry, Gary Cornell, Tony Davis, Steven Rycroft, Julian Skinner, Martin Streicher, Jim Sumser, Karen Watterson, Gavin Wray, John Zukowski Assistant Publisher: Grace Wong Project Manager: Nate McFadden Copy Editor: Ami Knox Production Manager: Kari Brooks Production Editor: Lori Bring Proofreader: Lori Bring Compositor: Argosy Publishing Indexer: Ron Strauss Cover Designer: Kurt Krames Manufacturing Manager: Tom Debolski The information in this book is distributed on an "as is" basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. To Cathy, Caroline, Nicholas, and Michael. You're everything I've ever wanted or needed in this world. Contents at a Glance Foreword ................................................................................................................. xvii About the Author ............................................................................................... xxi About the Technical Reviewer .................................................................. xxiii Acknowledgments ................................................................................................... xxv Introduction .................................................................................................... xxvii Chapter 1 Getting Started ...................................................................... 1 Chapter 2 ADO.NET ..................................................................................... 29 Chapter 3 Query Analyzer .................................................................. ,... 51 Chapter 4 SQL Server CE Data Definition Language ................... 69 Chapter 5 Metadata ................................................................................. 107 Chapter 6 Data Manipulation Language .......................................... 139 Chapter 7 Operator Reference ........................................................... 181 Chapter 8 Function Reference ........................................................... 227 Chapter 9 Remote Data Access ........................................................... 311 Chapter 10 Replication ........................................................................... 361 Appendix The •NET Compact Framework Class Libraries ....... 395 Index ......................................................................................................................... 433 v Contents Foreword .......................................................................................... xvii About the Author ........................................................................ xxi About the Technical Reviewer ........................................... xxiii Acknowledgments ............................................................................ xxv Introduction ............................................................................. xxvii Chapter 1 Getting Started ....................................... 1 What This Book Is All About ................................................... 1 System Requirements .................................................................... 2 Development ................................................................................. 3 Deployn1ent .................................................................................. 4 ActiveSync All Over Again ....................................................... 5 Installation .................................................................................... 5 Get Connected .............................................................................. 6 Smart Device Extensions Walkthrough ................................. 9 Smart Device Application Wizard ............................................. 10 Forms Designer ........................................................................... 13 References ................................................................................... 16 Project Properties ....................................................................... 17 Sending Extra Files ..................................................................... 18 Let's Run It .................................................................................. 19 Security Considerations ......................................................... 22 Device Security ........................................................................... 23 Database Security ....................................................................... 24 Future Issues ............................................................................... 25 Deployment ...................................................................................... 25 Deploying the .NET Compact Framework and SQL Server CE ...................................................................... 25 Deploying Your Application ...................................................... 26 Deployn1ent Options .................................................................. 26 Conclusion ...................................................................................... 27 vii Contents Chapter 2 ADO.NET .......................................................... 29 Namespaces ...................................................................................... 30 System.Data ................................................................................. 30 System.Data.Common ............................................................... 30 System.Data.SqlClient ................................................................ 30 System.Data.SqlServerCe ........................................................... 31 The SqlCeConnection Class ..................................................... 31 Error Handling ............................................................................ 34 The SqlCeCommand Class ............................................................ 36 Parameterized Queries ............................................................... 38 Transactions ................................................................................ 40 The SqlCeDataReader Class .................................................... .43 The SqlCeDataAdapter Class ................................................. ..46 Conclusion ...................................................................................... 49 Chapter 3 Query Analyzer ........................................ 51 Installation ........................ ,......................................................... 51 Overview ,......................................................................................... 52 The Objects Tab .............................................................. ,............ 53 Connecting to an Unmanaged Database .................................. 53 Disconnecting from a Database ................................................ 55 Compacting a Database ................................................... , ......... 55 Deleting Databases ..................................................................... 55 Connecting to a Managed Database ......................................... 56 Showing and Hiding System Tables .......................................... 56 Retrieving Table Data .......................................... , ...................... 56 Removing Managed Databases ................................................. 57 Creating Databases , .................................................................... 57 Creating Tables ......................................................................... ,.58 Adding Columns ......................................................................... 60 Creating Indexes ......................................................................... 61 Deleting Database Objects ......................................................... 63 The SQL Tab .................................................................................... 63 Creating a New SQL Script File .................................................. 63 Saving a SQL Script File .............................................................. 65 Opening a SQL Script File .......................................................... 65 Saving Frequently Used SQL Statements .................................. 66 Opening a Saved SQL Statement ............................................... 67 Conclusion