2011-03-08 11 views
0

VS 2010を使用してOutlook 2010用のアドインを作成しています。ローカルにデータを格納する方法を探していましたが、たくさんの人がSql CEを提案していました。私はそれを試してみたと ファイル名が有効ではありません。このエラーに走り続けた:データソース= | DataDirectoryの| \ data.sdfSqlServerCeファイル名が正しくありません

string conString = Properties.Settings.Default.dataConn; 

     SqlCeConnection dbConn = new SqlCeConnection(conString); 

     try 
     { 
      using (SqlCeConnection con = new SqlCeConnection(conString)) 
      { 
       con.Open(); 
      } 
     } 
     catch(Exception e) 
     { 
      MessageBox.Show(e.ToString()); 
     } 

私はここに示されているチュートリアルを使用: http://www.dotnetperls.com/sqlce

どれでも助けをだろうありがとう!

ありがとうございました。

答えて

0

| DataDirectory |実行時に展開される接続文字列内の特殊変数です。

- For applications placed in a directory on the user machine, this will be the app's (.exe) folder. 
    - For apps running under ClickOnce, this will be a special data folder created by ClickOnce 
    - For Web apps, this will be the App_Data folder 

これはOutlookプラグインでは機能しません。私はそれが値を設定していない実行中のコンテキストを推測しています。 (| DataDirectoryの|交換)あなたは、接続文字列にデータベースへの完全なパスを提供するいずれか試すことができますか、次を使用して動的にアプリケーションドメインでのDataDirectoryの値を設定:

AppDomain.CurrentDomain.SetData("DataDirectory", newpath) 

は用Working with local databasesを見てください詳しくは。

関連する問題