Link to home
Start Free TrialLog in
Avatar of wiswalld
wiswalldFlag for United States of America

asked on

Connect to sdf file on pocket pc

I simply want to connect to an sdf file on a pocket pc with a connection string from a desktop application. I think this should be simple. Then select all records from a table and copy to an sdf file on the desktop. I have looked into rda and other solutions but they seem to confusing. There has to be an easier way.

What about a connection string like this

Dim SqlConn As SqlCeConnection
        Dim DataPath As String
        DataPath = "\DVADGolf.sdf"
        SqlConn = New SqlCeConnection("Data Source=" & DataPath)
        SqlConn.Open()
        Dim DA As SqlCeDataAdapter
        DA = New SqlCeDataAdapter
        Dim Str_Sql As String
        Str_Sql = "Select * from tblplayer"
        Dim CmdSelect As SqlCeCommand
        CmdSelect = New SqlCeCommand(Str_Sql, SqlConn)
        DA.SelectCommand = CmdSelect
        Dim DS As DataSet
        DS = New DataSet
        SqlConn.Close()


I will not need the bottom part. I just copied some code I found. I will need to add an update statement or insert (I think)
ASKER CERTIFIED SOLUTION
Avatar of alexey_gusev
alexey_gusev
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wiswalld

ASKER

You are really shooting me down. I thought a simple connection string like this would work

Imports System.Data.SqlServerCe

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim connection As SqlCeConnection
        connection = New SqlCeConnection("Data Source=\MyDatabase.sdf")
        connection.Open()
    End Sub
End Class
as you can see e.g. here (http://msdn.microsoft.com/en-us/library/aa226134(SQL.80).aspx) it is for Compact Framework. Your code will work perfectly well on Windows Mobile, but not from desktop to PDA

or I completely misunderstood you?
No I think you got me. I want to connect to an sdf file on a mobile device and copy table data to an sdf file on a desktop. I want to create an application using an sdf file to avoid having to have clients use sql server. So I wanted to create a desktop windows application with a button that will open the connection to the pocket pc and copy records to the desktop sdf file.
thus that's no way to do it (I hope I am wrong :) , but it seems to be just hard fact)

but you still can employ the 2nd solution I mentioned, that is, using RAPI and C++ dll on PDA which your desktop app can talk to
I am not using C++. I was hoping to use vb.net. Can this work the other way. A sync button the pocket pc to connect to the desktop