Home All Groups Group Topic Archive Search About

How Do I connect to a Mobile SQL DB from VB2005 - Windows App

Author
9 Dec 2005 10:30 PM
Dave_C
I have both used the Data Connection Wizard and tried programatically to
connect to a Mobile SQL Database from within a Windows Application and keep
on getting the same Error at the connection point

"Unspecified error [ sqlcese30.sys.dll ]"


The Debug message is

" A first chance exception of type 'System.Data.SqlServerCe.SqlCeException'
occurred in System.Data.SqlServerCe.dll"

I have added a reference to
C:\ Program files\Microsoft Visual Studio 8\Common7\IDE\Public
assemblies\System.Data.SqlServer.Ce.dll.

I need to access the data from the pocket pc on a desktop computer. Is this
possible under VS2005 using VB or do I in actual fact need to purchase SQL
Server 2005 to achieve this. It was easy in VB6 using ActiveSync to move from
cdb to mdb but there seems to be no such converter for sdf to mdf and no
apparent ability to open sdf from within Windows Apps.

Any help is greatly appreciated.

Regards
David

Code enclosed

        Dim FileSpec As String = "Data Source = C:\Program Files\Microsoft
Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v3.0\Northwind.sdf"
        Dim MyConnection As New SqlServerCe.SqlCeConnection(FileSpec)
        MyConnection.Open()
        Dim da As New SqlServerCe.SqlCeDataAdapter("SELECT * FROM Orders",
MyConnection)
        Dim ds As DataSet = New DataSet
        da.Fill(ds, "Orders")

        'fill the textbox with one field to confirm the connection
        TextBox1.Text = ds.Tables(0).Rows(0)("Order ID")

AddThis Social Bookmark Button