简体   繁体   English

通过ActiveSync从Windows ce应用程序连接sql server而不连接网络

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

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? 我已经通过支架(Windows Mobile Device Center)将具有Windows CE 5的Motorola MC3090R与具有Windows 7(没有网络)的笔记本电脑相连,我的问题是我将如何从以下位置连接到sql server(位于笔记本电脑上)我的掌上电脑应用程序? what will be my connection string inside my handheld app? 掌上电脑应用程序中的连接字符串是什么? as there is no network what ip i will use in the connection string? 由于没有网络,我将在连接字符串中使用什么IP?

please help 请帮忙

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) 我有两个实例MYPC \\ SQL2005和MYPC \\ SQL2008,然后在MYPC上安装了SQL 2005 Express(无实例)

When you say "connected through cradle" I assume you are using Active Sync on the device. 当您说“通过通讯座连接”时,我假设您正在设备上使用Active Sync。 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. 如果是这种情况,您将为您的连接分配一个动态IP地址,在此问题的答案中,您将找到如何检索此地址,以便可以使用它来建立连接字符串。

If I understand your setup 如果我了解您的设置

PDA -> PC ->Sql Server(Remote). PDA-> PC-> Sql Server(远程)。

If that's the setup you can configure via the Windows Mobile Device Center. 如果是这样的设置,则可以通过Windows Mobile设备中心进行配置。

  1. Connect the device to your PC 将设备连接到PC
  2. Open Windows Mobile Device Center 打开Windows Mobile设备中心
  3. Click on Mobile Device Settings 点击移动设备设置
  4. Connection Settings. 连接设置。
  5. Select 'The Internet' on the combo 'This computer is connected to:' 在“此计算机已连接到:”组合上,选择“ Internet”。
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();
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM