Hi,
I am trying to make a mobile application work, but I get the following error. The operating system on Pocket PC is Microsoft? Windows Mobile? 2003 Second Edition. Any ideas? Thanks in advance.
The followings are the error and my codes:
System.TypeLoadException was unhandled
Message="Could not load type 'System.Data.SqlServerCe.SqlCeDataAdapter' from assembly 'System.Data.SqlServerCe, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91'."
StackTrace:
at SQLMobile.Form1.Form1_Load()
at System.Windows.Forms.Form.OnLoad()
at System.Windows.Forms.Form._SetVisibleNotify()
at System.Windows.Forms.Control.set_Visible()
at System.Windows.Forms.Application.Run()
at SQLMobile.Form1.Main()
Codes:
Private Sub FillGrid()
Dim filename As New String _
("\Program Files\SQLMobile\sqlmobile.sdf")
Dim conn As New SqlCeConnection("Data Source=" + filename)
Dim selectCmd As SqlCeCommand = conn.CreateCommand()
selectCmd.CommandText = "select Destination from flightdata"
Dim adp As New SqlCeDataAdapter(selectCmd)
Dim ds As New DataSet()
adp.Fill(ds)
DataGrid1.DataSource = ds
End sub
First, make sure the version of the System.Data.SqlServerCe is the correct one for Compact Framework 2.0 (not the CF1 version which only works with SQL CE 2.0)
Next, uninstall then reinstall SQL Mobile CABs on your device.
Finally, don't use the SqlCeDataAdaper to populate that DataSet - it is the absolute slowest option! Use either the SqlCeDataReader or the SqlCeResultSet to do so.
Darren
No comments:
Post a Comment