locked
Connection issues with Device Emulator RRS feed

  • Question

  •  

    Hi,

    I am trying to use RDA to create a database on mobile device and for data synchronization.

     

    To make sure RDA works ok for me, I created a VB.NET application on desktop and successfully used RDA Pull and Push methods.

     

    But when I tried to create the same project for Mobile I am not able to connect to the database from device emulator (Windows Mobile 5.0 Pocket PC R2 Square Emulator).

     

    Error message is "a request to send data to the computer running IIS has failed. For more information, see HRESULT"

     

    On some trouble shooting I found that it is failing to connect to SQL server using rdaOledbConnectString.

     

    Following is the code I am using. The same rdaOledbConnectString is working perfectly ok from VB.Net desktop application. Could anybody help me to find out how to check HRESULT and if something is wrong in the code.

     

    Thank you.

    Shyam

     

    Code: (based on the webcast http://channel9.msdn.com/ShowPost.aspx?PostID=209467)

     

    Public Class Form1

    Dim rdaOledbConnectString As String = "Provider=SQLOLEDB;Data Source=<IP Address>;Persist Security Info=True;Initial Catalog=RDA_Test;userid=password;password=password"

    Dim rdaurl = "http://localhost/SqlMobile/sqlcesa30.dll"

    Dim localconnection = "Data Source=\my documents\RDA_Test.sdf"

     

    Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click

    Try

    If File.Exists("\my documents\RDA_Test.sdf") Then

    File.Delete("\my documents\RDA_Test.sdf")

    End If

     

    Dim engine As New SqlCeEngine

    engine.LocalConnectionString = localconnection

    engine.CreateDatabase()

    engine.Dispose()

     

    Dim rda As New SqlCeRemoteDataAccess(rdaurl, localconnection)

    rda.InternetUrl = rdaurl

    rda.LocalConnectionString = localconnection

    rda.Pull("Physician", "select * from physician", rdaOledbConnectString, RdaTrackOption.TrackingOn)

    rda.Dispose()

     

    MessageBox.Show("Done")

    Catch ex As Exception

    MessageBox.Show(ex.ToString())

    Finally

    Windows.Forms.Cursor.Current = Cursors.Default

    End Try

     

    End Sub

    End Class
    Friday, May 16, 2008 4:38 PM

Answers

  • Oop - one more thing... "localhost" means "the DeviceEmulator's IP address" when you run code inside the emulator.  Your sample code uses "localhost", and that may not be what you want.

     

    Barry

     

     

    Saturday, May 17, 2008 4:26 PM

All replies

  • Without the HRESULT value, it's hard to diagnose what went wrong.

     

    How is the emulator configured, to communicate back to the webserver?   The best way is to launch the Device Emulator Manager from the Tools menu in Visual Studio, then right-click on the entry corresponding to your emulator, and pick "Cradle".

     

    Otherwise, it could be a firewall issue... the DeviceEmulator appears to the host PC as a remote device, outside of the PC's firewall.

     

    Barry

     

     

     

     

    Saturday, May 17, 2008 4:25 PM
  • Oop - one more thing... "localhost" means "the DeviceEmulator's IP address" when you run code inside the emulator.  Your sample code uses "localhost", and that may not be what you want.

     

    Barry

     

     

    Saturday, May 17, 2008 4:26 PM
  • Thanks Barry. I changed Localhost to the computer name and it worked for me!!

    Monday, May 19, 2008 11:07 PM