MS SQL Server
  Home arrow MS SQL Server arrow Page 5 - Developing SQL Server CE based Pocket PC A...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

Developing SQL Server CE based Pocket PC Applications using Visual Studio.NET
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 20
    2006-05-17

    Table of Contents:
  • Developing SQL Server CE based Pocket PC Applications using Visual Studio.NET
  • Installing SQL Server CE onto a Pocket PC emulator: developing the application
  • Installing SQL Server CE onto a Pocket PC emulator: deploying the application
  • Where did the installation actually take place in the Pocket PC?
  • Creating an SQL Server CE database programmatically

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Developing SQL Server CE based Pocket PC Applications using Visual Studio.NET - Creating an SQL Server CE database programmatically


    (Page 5 of 5 )

    Now, it is time to create an SQL Server CE database programmatically (or dynamically). 

    To work with SQL Server CE, we need to import two namespaces (which are to be referred as shown in previous sections), namely "System.Data.Common" and "System.Data.SqlServerCe." 

    To create (or manage) an SQL Server CE database, we need to work with the class "System.Data.SqlServerCe.SqlCeEngine."  We need to create an object out of it and call a method, "CreateDatabase," which simply creates a database based on the connection string we pass (along with an optional password).  It is always a good idea to "dispose" of the "SqlCeEngine" once it completes its job.

    Putting it all together, you can modify your code in the previous example in such a way that it looks like the following:

    Imports System.Data.Common
    Imports System.Data.SqlServerCe
    Public Class Form1
        Inherits System.Windows.Forms.Form
        Friend WithEvents Button1 As System.Windows.Forms.Button
    .
    .
    .
    .
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
                Dim connStr As String
                connStr = "Data Source = emp.sdf; Password = jagchat"
     
                Dim engine As SqlCeEngine
                engine = New SqlCeEngine(connStr)
                engine.CreateDatabase()
                engine.Dispose()
                MessageBox.Show("Successfully created")
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        End Sub
    End Class

    Execute the above code by pressing F5.  Once you click on "Button1," you should be able to see a message box showing "Successfully created."  You can check the file "emp.sdf" in your root directory (or in "My Device" as specified in the previous section) as shown in the following image (fig12).

    You can try clicking on the file (emp.sdf) to open it using Query Analyzer.  It will give the message "Invalid Password" and ask for the password.  Once you provide the password (in this case it is "jagchat"), it will open the database (which is generally empty) and show something like the following (Fig13).

    I developed the application using Microsoft Windows Server 2003 Standard Edition with Microsoft Visual Studio.NET 2003 Enterprise Architect and Pocket PC SDK 2003 (along with additional emulators downloaded). The entire solution for this article is freely available in the form of a zip downloadable. 

    In my upcoming articles, I shall concentrate further on developing advanced Pocket PC applications.  So, keep close tabs on this website :)

    Any comments, suggestions, feedback, bugs, errors, enhancements are highly appreciated at jag_chat@yahoo.com


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hello guys, contributed another on developing Pocket PC applications. Enjoy and give...
     

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway