connecting sql server from windows ce application through Activesync without being on network

ⅰ亾dé卋堺 提交于 2019-11-30 10:01:31

问题


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


回答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)




回答2:


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.




回答3:


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:'



回答4:


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();
        }
    }


来源:https://stackoverflow.com/questions/6846591/connecting-sql-server-from-windows-ce-application-through-activesync-without-bei

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!