应该用这样的格式吧Data Source=.\SQLEXPRESS;AttachDbFileName=e:\data\Customers.mdf;Integrated Security=True;User Instance=True

解决方案 »

  1.   

    using System;
    using System.IO;
    using System.Reflection;
    using System.Runtime.InteropServices;    public class Configs
        {
            private string m_CurrentPath;        private string Platform
            {
                get
                {
                    return Environment.OSVersion.Platform.ToString();
                }
            }        public string CurrentPath
            {
                get
                {                if (Platform.Equals("WinCE"))
                    {
                        m_CurrentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
                    }
                    else if (Platform.Equals("Win32NT"))
                    {
                        m_CurrentPath = Directory.GetCurrentDirectory();
                    }                return m_CurrentPath;
                }
            }        public Configs()
            {        }
        }
    用这个类获得你数据文件的位置,然后用            
    SqlCeConnection conn = new SqlCeConnection("Data Source = " + MyPath.CurrentPath.ToString() + "\\MyNotes.sdf;");