DEVBUZZ Homepage .NET Compact Frameworks & the ADO.NET Data Adapter
 
Web www.devbuzz.com
  HOME PAGE
  All Articles
  Advertise
  Consulting

 Development
  Discuss - Forums
  Still in the box?
  .Compact Framework
  Code Snippets
  SQL Server CE
  Database
  MS Resources
 Stores
  Developer Controls
  Pocket PC Hardware
  Pocket PC Software
  Pocket PC Books
  .NET CF Books
  Book Reviews
  SPB SW Discounts
  RESCO SW Discounts
 DEVBUZZ Info
  About Us
  Help
  Join our email list
  Links & Ratings
  Press & Comments
  Pocket PC version
  Software Reviews
  Hardware Reviews
 Authors
  Authors
  Article Guide
  Competitions
 Resources
  Developers
  Register
  Login

  SPB Discounts!
 Columnists
  Rick Winscot
 Past Blast
  Personal Media Ctr
  Gizmobility
  eVB Legacy
  Old news
  Hosted Software
  Wireless
  Newsletters
  Carl Davis
  Upton Au

 Pocket PC Registry
  Join the registry
  View current list
 Current Poll
Are you converting to .NET Compact Framework?
Yes, it has changed my life!
No, I'm sticking with eVB
.NET CF what's that`?

Current results
3431 votes so far
 Recent Forum Threads [goto forums]

Get Computername
read... (67 hits)


Great aid to development productivity
read... (82 hits)


ThreadingTimer sample code
read... (143 hits)


Multithreading with .NET CF
read... (194 hits)


Moving from eMbedded Visual Basic to Visual Basic .NET
read... (166 hits)


.NET Compact Framework 2.0 Service Pack 2
read... (226 hits)


Transfer Data from SQL Server 2000 to SQL Server Compact Edition
read... (298 hits)


This protocol version is not supported
read... (236 hits)


Converting Lowercase to uppercase wont work
read... (203 hits)


Direct access to MS SQL Server 2000
read... (374 hits)


Creating SDF file in Desktop
read... (513 hits)


Winsock in CF.NET
read... (316 hits)


Using Pocket Outlook to submit HTML page form with MAILTO action
read... (420 hits)


Missing file "System.Data.PocketPC.asmmeta.dll"
read... (268 hits)


HP iPAQ hw6915 Serial Port Issue
read... (309 hits)


Info on the recent forum changes
read... (341 hits)


SqlServer tools from Redgate
read... (383 hits)


Arrow keys and Hardware navigation button
read... (393 hits)


O2 XDA lls pin sync cable to comport
read... (322 hits)


Creating dynamic folders on Pocket PC OS
read... (299 hits)

Custom Windows Mobile software development.
LBS Challenge 2007
LBS Challenge Eight previous NAVTEQ Global LBS Challenge® participants have received venture capital funding and nine past LBS Challenge winners have launched commercial applications on major wireless carriers. Register your non-commercial LBS application in the 2007 NAVTEQ Global LBS Challenge in one of three regions: Americas, Europe-Middle East-Africa (EMEA) or Asia-Pacific(APAC). You could win a share of $2 million in prizes. This could be your year.
Dream. Develop. Win.

Development | .NET Compact Framework

.NET Compact Frameworks & the ADO.NET Data Adapter
Written by Derek Mitchell  [author's bio]  [read 58290 times]
Edited by Derek

Download the code   Discuss this article   .NET Compact Framework   

Page 1  Page 2  Page 3 

.NET Compact Frameworks & the ADO.NET Data Adapter

So you've been toying with jumping on the .NET cf bandwagon for months now right? Get with the program! .NET is definitely the way to go. For me it has been a tremendous learning curve to embrace and it is pretty the process is pretty much ongoing. In many ways one of the biggest challenges to .NET is coming to terms with the myriad of ways that you can architect solutions. eVB is pretty limiting and this makes things pretty easy from the perspective that there is often only one way to do it. I also got very tired of the amount of work around code required to build menus or tabs, work with XML etc., so welcome to the future - .NET Compact Framework - sure it's not the universal panacea to all mobile development but it is a huge improvement.

One of the biggest challenges in adapting to .NET is getting to grips with the new data access methodology - ADO.NET. OLE DB providers are no longer used, instead they have been usurped by .NET managed providers which are used to manage data access between the data source and your application. This may seem like an extension of the OLE dB provider approach but that is where the similarity ends. Under the hood the implementation is very different and COM has been removed from the equation. Server-side cursor support has been dropped in ADO.NET owing to the server performance and locking penalties; consideration being cast rather in favor of forward-only, read-only resultsets.

So we have established that ADO.NET is definitely the subject of whole tomes of information; before you continue too far down this path you need to have a look at Larry Roof's article called Smart Device Extensions, SQL Server CE, and Me - this will give you a great overview of the SDE environment and the basics of SQL Server CE.

Now we get to the fun part. I was putting together a tutorial on how to use combo-boxes in .NET CF and was generating some XML to use as test data. Actually the original idea here was to do some perforce testing on datasets when I lost focus and got onto the combo-box idea (more about this next week!). So my plan was that I would provide an XML file in the tutorial and then instantiate the SQL Server CE database from the XML. This is where the flexibility of the .NET data adapters and data sets really becomes apparent. So what is a dataset you ask. Think of it as your private in-memory data storage object. You can utilize one dataset populating it from different date sources, setting up relationships between the data tables it contains and then write the changes back to their respective sources. Another thing you can do is create a dataset from one source and then use a data adapter to write it to another source essentially using the data adapter as an update bridge. All this pretty easily too.

 

Remember to delete the devbuzztest.xml file from the Windows directory on your device after you have run the attached app - it will save you just under a 100k.

Form Load

On the form load event we create an instance of the dataset object as well as instantiating a a new SQLHelper object.

data = New DataSet()
sql = New SQLHelper()

The SQLHelper class has the usual suspects providing connectivity and SQL CE error checking, as well as some additional functionality like the TableExists function:

Function TableExists(ByVal pTableName As String) As Boolean
Dim SQL As String = "SELECT TABLE_NAME FROM " & _
"INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '" & _
pTableName & "'"
If ceConnect() Then
Dim sqlReader As SqlCeDataReader
Dim sqlCmd As New SqlCeCommand(SQL, connCE)
Try
sqlReader = sqlCmd.ExecuteReader
Catch err As SqlCeException
ErrorDisplay(err)
Catch err As Exception
MsgBox("There was an error: " & err.ToString())
End Try
If sqlReader.Read Then
'found the name?
TableExists = True
Else
TableExists = False
End If
sqlReader = Nothing
sqlCmd = Nothing
Disconnect()
End If
End Function

Next Page 

Back to .NET Compact Framework | [Article Index]

 

Back to the top of the page.
Chris De Herrera's Windows CE Website Windows CE News & Information Source
Copyright ©2000-2007 by DEVBUZZ.COM, Inc., NJ. USA.MSDEVELOP