0

I've connected my Motorola MC3090R having Windows CE 5 through cradle (Windows Mobile Device Center) with my laptop having Windows 7 (there is no network), my question is that how i will connect to sql server (it's on my laptop) from my handheld app? what will be my connection string inside my handheld app? as there is no network what ip i will use in the connection string?

please help

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Adnan Badar
  • 347
  • 2
  • 5
  • 14

4 Answers4

1

I solved it with this connection string.

m_Desktopconn = New SqlConnection(
  "Data Source=192.168.55.100,1433;Initial Catalog=Testing;Persist Security Info=True;User ID=sa;Password=sa;")

I had two instances MYPC\SQL2005 & MYPC\SQL2008, and then installed SQL 2005 Express on MYPC (Without instance)

p.campbell
  • 98,673
  • 67
  • 256
  • 322
Adnan Badar
  • 347
  • 2
  • 5
  • 14
0

When you say "connected through cradle" I assume you are using Active Sync on the device. If that is the case, you will have a dynamic IP address assigned to your connection, in answers to this question you will find how to retrieve this address so that you can use it to build the connection string.

Community
  • 1
  • 1
yms
  • 10,361
  • 3
  • 38
  • 68
  • Dear yms, I've tried System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList(0) its giving me {System.Net.IPAddress} Address: 1698146496 AddressFamily: InterNetwork {2} Any: {System.Net.IPAddress} Broadcast: {System.Net.IPAddress} IPv6Any: {System.Net.IPAddress} IPv6Loopback: {System.Net.IPAddress} IPv6None: {System.Net.IPAddress} Loopback: {System.Net.IPAddress} None: {System.Net.IPAddress} ScopeId: {"The attempted operation is not supported for the type of object referenced"} there is no ip for PC – Adnan Badar Jul 28 '11 at 06:56
  • by the way i am using Windows Mobile Device Center with my laptop having Windows 7 without network – Adnan Badar Jul 28 '11 at 08:10
  • And you are using 'System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList(0) ' from the device, within your WinCE application, right? – yms Jul 28 '11 at 10:53
  • yes sir from my windows ce app and even i put
    `For Each obj As Object In System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList MessageBox.Show("") Next`
    which is just running once and showing the above detail {System.Net.IPAddress} Address: 1698146496 .......
    – Adnan Badar Jul 28 '11 at 11:36
  • Got it working! m_Desktopconn = New SqlConnection("Data Source=192.168.55.100,1433;Initial Catalog=Testing;Persist Security Info=True;User ID=sa;Password=sa;") first i had two instances MYPC\SQL2005 & MYPC\SQL2008 then i install SQL2005Express on MYPC (Without instance) and nows it is working fine. Thank you all for your kind support & time, God bless us all. – Adnan Badar Jul 31 '11 at 10:08
0

If I understand your setup

PDA -> PC ->Sql Server(Remote).

If that's the setup you can configure via the Windows Mobile Device Center.

  1. Connect the device to your PC
  2. Open Windows Mobile Device Center
  3. Click on Mobile Device Settings
  4. Connection Settings.
  5. Select 'The Internet' on the combo 'This computer is connected to:'
R Quijano
  • 1,301
  • 9
  • 10
  • Thanks Quijano i will try this, but what will be the server name or ip address in the connection string because i won't have any network connect to the end user desktop, i mean if there will be no network then how my windows ce app connect using connection string? – Adnan Badar Jul 29 '11 at 12:20
  • Got it working! m_Desktopconn = New SqlConnection("Data Source=192.168.55.100,1433;Initial Catalog=Testing;Persist Security Info=True;User ID=sa;Password=sa;") first i had two instances MYPC\SQL2005 & MYPC\SQL2008 then i install SQL2005Express on MYPC (Without instance) and nows it is working fine. Thank you all for your kind support & time, God bless us all. – Adnan Badar Jul 31 '11 at 10:07
  • Whenever I try to connect the sql server from device it is showing some connection error, let me also try this – Jobin Joseph Aug 07 '16 at 07:03
  • thank you! I can also select "work network" which allows me to connect to the sql server on my local domain. This solved my connectivity problem that I was fighting against for two days straight. – user819490 Sep 09 '16 at 19:22
-1
private void form1Load(Object sender, EventArgs e)
        {
            String strConnection =
                "Data Source=your_ip;Initial Catalog=your_database;Integrated Security=True; User ID=your_db_user;Password=your_db_password;";

        try
        {
            conn = new SqlConnection(strConnection);
            conn.Open();
            MessageBox.Show("You Success!!");
        }
        catch (SqlException ex)
        {
            MessageBox.Show("You failed!" + ex.Message);
            conn.Close();
        }
    }
Micho
  • 3,929
  • 13
  • 37
  • 40