Emulator failing to connect to SQL Server

935 Views Asked by At

I am very new to programming. My company gave me some code for debugging. I am testing a Pocket PC application. No matter what ever I do I can't connect to SQL Server.

First I got the error the server doesn't exist. Second time I have error like server not accessible. I wrote simple code in device application in VS 2008 in vb.net.

The same code runs fine in a Windows forms (I am able to connect to database and pull data). But it fails in device application. I have the following code:

 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim con As SqlConnection
        Dim cmd As SqlCommand
        Dim row As Integer
        'Dim str As String
        con = New SqlConnection("Server=w****b;Database=p***5;User Id=d****;Password=*****;")

        con.Open()

        cmd = New SqlCommand("select * from emp", con)
        row = cmd.ExecuteNonQuery()

        If row > 0 Then
            MessageBox.Show("the row inserted" & row)
        End If

        con.Close()
    End Sub

I configured the emulator network property as

Enable NE2000 PCMCIA network adapter and bind to

connected network card.

After this I am getting a new error

SQL Server requires Encryption On

I checked the server and encryption is already enabled.

Does anybody know how to connect to SQL Server using emulator? It is high priority job and I am stuck because I can't do anything unless I am able to connect to a database. Any help would be appreciated.

1

There are 1 best solutions below

1
josef On

AFAIK the NE2000 emulated networc card is not available since Windows XP. When I need a network connected Emulated Windows Mobile image, I 'dock' the running emultaed mobile device using the Device Emulator Manager (part of standalone device emulator package). Then with WMDC (ActiveSync) active on the development PC and Connection:DMA enabled, the emulated evice get's connected to the PC's network.

On the SQL Server TCP/IP Transport must be enabled. In the connection string use the IP-address of the sql server.

I did not see the "connection must be encrypted" error with standard setups.

You should also look at the SQL Server's event log for the connection error.

BTW: you can run the Windows Mobile compiled exe also on PC as long as the code does not use Mobile-only API functions.