Unable to load data from database

Answered Unable to load data from database

  • Wednesday, September 12, 2012 2:12 AM
     
      Has Code

    I have a WinForms application that I have placed on a test computer (copied the .sdf file and the executable from the release folder) running Windows 7 32bit. When I run the program I get this error message:

    Could not load file or assembly 'System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc01' or one of its dependencies. The system cannot find the file specified. 

    The test computer has both SQL Server 2005 Compact Edition and SQL Server Compact Edition 4.0 installed. The .sdf file and the executable are located in the Program Files folder. I've set the program to search for the database in this location:

    Program.CS

    string directoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "\\MedNote");
                AppDomain.CurrentDomain.SetData("DataDirectory",  directoryPath);

    queryAbbrevDB.cs

    SqlCeConnection connection = new SqlCeConnection(@"Data Source=|DataDirectory|\keywordDB.sdf");

    Since the error says that the file cannot be found I'm assuming that I'm calling the file incorrectly. Though, I'm not sure what I'm doing wrong. Could someone please guide me in the right direction?


    -- Tyler Hughes

All Replies