2017-09-18 97 views
1

請幫忙。 我有設備MC3200 Zebra(摩托羅拉)(Windows Embedded版本7,版本2864)。該設備正在連接到網絡並查看SQL服務器(ping可以)。我用它的Visual Studio 2008,C#,SmartDevicePrj,.NET CF 3.5如何將windows CE c#應用程序連接到數據庫SQL Server2008r2

enter image description here

但之後在設備上啓動應用程序將顯示消息:

在連接字符串中未知的連接選項:初始目錄。

一些想法如何修復它?

非常感謝您的幫助。

using System; 
    using System.Linq; 
    using System.Collections.Generic; 
    using System.ComponentModel; 
    using System.Data; 
    using System.Drawing; 
    using System.Text; 
    using System.Windows.Forms; 
    using System.Data.SqlServerCe; 

namespace SmartDeviceProject1 
{ 
    public partial class Form1 : Form 
    { 
     public SqlCeConnection msConn; 
     public string strCon = ""; 
     public SqlCeCommand command; 

     public Form1() 
     { 
      InitializeComponent(); 
      strCon = "Data Source=server007; Initial Catalog=FMPredlis; User ID=mistr; Password=heslo;"; 
      try 
      { 
       msConn = new SqlCeConnection(strCon); 
       msConn.Open(); 
       MessageBox.Show("Připojeno"); 
      } 
      catch (SqlCeException ex) 
      { 
       MessageBox.Show("Chyba" + ex.Message); 
       msConn.Close(); 
      } 
     } 
    } 
} 
+0

確定Windows CE設備可以查找名爲「server007」的名字? – BugFinder

+0

IIRC,SqlCeConnections被指定爲「Data Source = MyData.sdf」,根本無法連接到「真實」SQL服務器。 – dlatikay

回答

0

我想你是混合2件事。

要麼使用SqlConnection對象,那麼你可以使用此頁面上發現了一個連接字符串連接到SQL Server: https://www.connectionstrings.com/sql-server/

或者在代碼中的SqlCeConnection使用像,那麼你連接到SQL精簡版(本地文件),你的連接字符串應該像這個頁面上: https://www.connectionstrings.com/sqlite/

但在你的示例中,你正在使用SqlCEConnection連接到一個sql服務器,這將無法正常工作。

Grtz

+0

是的,我其實混合了兩件事。在項目開始時,我遇到了一個System.Data.SqlClient引用的問題,所以我走開了。 現在一切正常。我仍然有一個dbnetlib.dll的問題,但我已經解決了它通過https://stackoverflow.com/questions/21838161/cant-find-pinvoke-dll-dbnetlib-dll-error-in-smart-device-application 非常感謝您的幫助! –

相關問題